pub trait BatchEncodable {
// Required methods
fn string(&self, data: &str) -> MemoryWriterResult<StrLocation>;
fn data(&self, data: &[u8]) -> MemoryWriterResult<()>;
fn end(&self) -> MemoryWriterResult<()>;
fn stop(self) -> MemoryWriterResult<CompletedInstructions>;
}
Expand description
BatchEncodable
defines a trait which allows you implement
conversion an underlying binary representation of a Batch
operation.
Required Methods§
Sourcefn string(&self, data: &str) -> MemoryWriterResult<StrLocation>
fn string(&self, data: &str) -> MemoryWriterResult<StrLocation>
[string
] encodes the underlying string
returning the string location information which allows
whatever is calling it
Sourcefn data(&self, data: &[u8]) -> MemoryWriterResult<()>
fn data(&self, data: &[u8]) -> MemoryWriterResult<()>
[data
] provides the underlying related data for
the identified operation.
Sourcefn end(&self) -> MemoryWriterResult<()>
fn end(&self) -> MemoryWriterResult<()>
[end
] is used to mark a portion of the batch as completed.
This allows to encode as much individual instructions
into a single batch so that we can take advantage of
treating a series of instructions as atomic operations
that should roughly depending on host handling be
executed together. This allows the host perform a
all or nothing operation if later desired but that is
beyond the scope here. We just want a way to clearly
articulate the end of a sub-instruction and the start
of another.
Sourcefn stop(self) -> MemoryWriterResult<CompletedInstructions>
fn stop(self) -> MemoryWriterResult<CompletedInstructions>
[end
] indicates the batch encoding can be considered finished and
added to the batch list.