Struct strymon_communication::message::MessageBuf [] [src]

pub struct MessageBuf { /* fields omitted */ }

A MessageBuf represents a contiguous buffer of MessagePack encoded objects. It can be used as a multi-part message to allow partial deserialization. Partial messages can be inserted using the push method and are read in first-in, first-out order by the pop method.

MessageBuf is a convenience wrapper around bytes::BytesMut and thus inherets the same properties: No allocation is required for small objects; clones are reference-counted and implement copy-on-write semantics.

Methods

impl MessageBuf
[src]

[src]

Create a new message buffer containing the serialized object.

[src]

Create a new, empty message.

Use one of the From impls to construct a message from an already existing buffer or object.

[src]

Returns true if the contained bytes have a length of zero.

[src]

Serialize and append an item to the message buffer.

[src]

Remove and deserialize the top item in the message buffer.

The object is not modified and kept in the buffer if deserialization fails. The push and pop operations implement FIFO semantics.

[src]

Peek at the top item in the message buffer. This borrows the buffer for zero-copy deserialization.

[src]

Copies the contained bytes into the provided writer.

Prepends the size of the message in bytes as a big-endian 32 bit unsigned integer.

[src]

Reads a message from a reader, expecting a frame length prefix.

If first read of the message length field fails with an ErrorKind::UnexpectedEof then Ok(None) is returned to indicate that the reader closed gracefully. All other read errors, most notably ErrorKind::WouldBlock, are propagated verbatim.

Trait Implementations

impl Clone for MessageBuf
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for MessageBuf
[src]

[src]

Formats the value using the given formatter. Read more

impl PartialEq for MessageBuf
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl Eq for MessageBuf
[src]

impl From<BytesMut> for MessageBuf
[src]

[src]

Performs the conversion.

impl Into<BytesMut> for MessageBuf
[src]

[src]

Performs the conversion.