Record Class DrawBatchResult

java.lang.Object
java.lang.Record
com.botwithus.bot.api.draw.DrawBatchResult
Record Components:
applied - commands the producer accepted
dropped - commands the producer refused
firstError - the producer's message for the first refusal, or "" when nothing was refused. There is no second message: the wire does not carry one.

public record DrawBatchResult(int applied, int dropped, String firstError) extends Record
What a batched submit actually achieved.

Read this, do not assume a batch succeeded. debug_draw_set_batch answers a normal success envelope even when it applied nothing: the per-item failures come back as a count and the first error string only, never as per-item {key, error}. A caller that checks only for a thrown RPC error will read a 256-item batch that drew nothing as a success. That is why DrawFrame.flush() returns this and why DrawFrame.close() logs a warning rather than swallowing it — a script that believes it has a highlight it does not have is the worst outcome available.

The mirror of that is worth knowing too: a batch that does fail at the envelope level is not a clean failure. The producer applies items to its store as it walks them, so you get no result at all while part of the batch may already be drawn. There is deliberately no DrawBatchResult for that case, because the wire carries no count with the error — see DrawFrame.flush() for what is recoverable and how.

  • Field Details

    • EMPTY

      public static final DrawBatchResult EMPTY
      The result of flushing nothing.
  • Constructor Details

    • DrawBatchResult

      public DrawBatchResult(int applied, int dropped, String firstError)
      Creates an instance of a DrawBatchResult record class.
      Parameters:
      applied - the value for the applied record component
      dropped - the value for the dropped record component
      firstError - the value for the firstError record component
  • Method Details

    • isComplete

      public boolean isComplete()
      True when every command in the batch was accepted.
    • submitted

      public int submitted()
      Total commands the batch carried.
    • merge

      public DrawBatchResult merge(DrawBatchResult next)
      This result combined with a later one, for a frame large enough to need more than one DrawLimits.MAX_BATCH_ITEMS-item batch. The earliest non-empty error wins, matching the single-batch contract that you are told about the first refusal only.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • applied

      public int applied()
      Returns the value of the applied record component.
      Returns:
      the value of the applied record component
    • dropped

      public int dropped()
      Returns the value of the dropped record component.
      Returns:
      the value of the dropped record component
    • firstError

      public String firstError()
      Returns the value of the firstError record component.
      Returns:
      the value of the firstError record component