Trait SectionBuilder

Source
pub trait SectionBuilder: Sized {
Show 13 methods // Required methods fn into_target(self) -> MessageTarget; fn get_target(&self) -> &MessageTarget; fn get_target_mut(&mut self) -> &mut MessageTarget; // Provided methods fn set_limit(&mut self, limit: usize) { ... } fn header(&self) -> &Header { ... } fn header_mut(&mut self) -> &mut Header { ... } fn preview(&self) -> &[u8] { ... } fn prelude(&self) -> &[u8] { ... } fn prelude_mut(&mut self) -> &mut [u8] { ... } fn finish(self) -> BytesMut { ... } fn freeze(self) -> Message { ... } fn snapshot(&self) -> Snapshot<Self> { ... } fn rewind(&mut self, snapshot: &Snapshot<Self>) { ... }
}
Expand description

Trait that implements common interface for building message sections

Required Methods§

Source

fn into_target(self) -> MessageTarget

Converts into target

Source

fn get_target(&self) -> &MessageTarget

Returns message target

Source

fn get_target_mut(&mut self) -> &mut MessageTarget

Returns message target

Provided Methods§

Source

fn set_limit(&mut self, limit: usize)

Updates the message’s size limit.

After this method was called, additional data will not be added to the message if that would result in the message exceeding a size of limit bytes. If the message is already larger than limit when the method is called, it will not be truncated. That is, you can never actually set a limit smaller than the current message size.

Note also that the limit only regards the message constructed by the builder itself. If a builder was created atop a buffer that already contained some data, this pre-existing data is not considered.

Source

fn header(&self) -> &Header

Returns a reference to the messages header.

Source

fn header_mut(&mut self) -> &mut Header

Returns a mutable reference to the messages header.

Source

fn preview(&self) -> &[u8]

Returns a reference to the message assembled so far.

In case the builder was created from a buffer with pre-existing content, the returned reference is for the complete content of this buffer.

Source

fn prelude(&self) -> &[u8]

Returns a reference to the slice preceeding the message.

The slice is may be empty.

Source

fn prelude_mut(&mut self) -> &mut [u8]

Returns a mutable reference to the slice preceeding the message.

Source

fn finish(self) -> BytesMut

Finishes the message and returns the underlying bytes buffer.

This will result in a message with empty authority and additional sections.

Source

fn freeze(self) -> Message

Finishes the message and returns the resulting bytes value.

This will result in a message with empty authority and additional sections.

Source

fn snapshot(&self) -> Snapshot<Self>

Returns a snapshot indicating the current state of the message.

The returned value can be used to later return the message to the state at the time the method was called through the rewind method.

Source

fn rewind(&mut self, snapshot: &Snapshot<Self>)

Rewinds the message to the state it had at snapshot.

This will truncate the message to the size it had at the time the snapshot method was called, making it forget all records added since.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§