Struct distant_net::common::Frame

source ·
pub struct Frame<'a> { /* private fields */ }
Expand description

Represents some data wrapped in a frame in order to ship it over the network. The format is simple and follows {len}{item} where len is the length of the item as a u64.

Implementations

Creates a new frame wrapping the item that will be shipped across the network

Consumes the frame and returns its underlying item.

Total bytes to use as the header field denoting a frame’s size

Returns the len (in bytes) of the item wrapped by the frame

Returns true if the frame is comprised of zero bytes

Returns a reference to the bytes of the frame’s item

Writes the frame to a new Vec of bytes, returning them on success

Writes the frame to the end of dst, including the header representing the length of the item as part of the written bytes

Attempts to read a frame from src, returning Some(Frame) if a frame was found (including the header) or None if the current src does not contain a frame

Checks if a full frame is available from src, returning true if a frame was found false if the current src does not contain a frame. Does not consume the frame.

Returns a new frame which is identical but has a lifetime tied to this frame.

Converts the Frame into an owned copy.

If you construct the frame from an item with a non-static lifetime, you may run into lifetime problems due to the way the struct is designed. Calling this function will ensure that the returned value has a static lifetime.

This is different from just cloning. Cloning the frame will just copy the references, and thus the lifetime will remain the same.

Trait Implementations

Returns a reference to this Frame’s item as bytes.

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Extends the Frame’s item with the provided bytes, allocating an owned Vec underneath if this frame had borrowed bytes as an item.

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more

Consumes the byte array slice and returns a Frame whose item references those bytes.

Consumes the byte slice and returns a Frame whose item references those bytes.

Test if Frame’s item matches the provided bytes.

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Test if Frame’s item matches the provided bytes.

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Test if Frame’s item matches the provided bytes.

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Test if Frame’s item matches the provided bytes.

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
Encode the hex strict representing self into the result. Lower case letters are used (e.g. f9b4ca) Read more
Encode the hex strict representing self into the result. Upper case letters are used (e.g. F9B4CA) Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.