Struct middleman::PackedMessage [] [src]

pub struct PackedMessage(_);

This structure represents the serialized form of some Message-implementing structure. Dealing with a PackedMessage may be suitable when: (1) You need to send/store/receive a message but don't need to actually use it yourself. (2) You want to serialize a message once, and send it multiple times. (3) You want to read and discard a message whose type is unknown.

NOTE: The packed message maps 1:1 with the bytes that travel over the TcpStream. As such, packed messages also contain the 4-byte length preable. The user is discocuraged from manipulating the contents of a packed message. The recv statement relies on consistency of packed messages

Methods

impl PackedMessage
[src]

[src]

Create a new PakcedMessage from the given Message-implementing struct

[src]

Attempt to unpack this Packedmessage given a type hint. This may fail if the PackedMessage isn't internally consistent or the type doesn't match that of the type used for serialization.

[src]

Unwrap the byte buffer comprising this PackedMessage

[src]

Accept the given byte buffer as the basis for a PackedMessage

WARNING: Use this at your own risk! The recv functions and their variants rely on the correct contents of messages to work correcty.

NOTE: The first 4 bytes of a the buffer are used to store the length of the payload.

[src]

Return the number of bytes this packed message contains. Maps 1:1 with the bit complexity of the message sent over the network.

[src]

Acquire an immutable reference to the internal buffer of the packed message.

[src]

Acquire a mutable reference to the internal buffer of the packed message.

WARNING: Contents of a PackedMessage represent a delicata internal state. Sending an internally inconsistent PackedMessage will compromise the connection. Use at your own risk!

Trait Implementations

Auto Trait Implementations

impl Send for PackedMessage

impl Sync for PackedMessage