pub enum NoAllocSliceSegments<'b> {
    SingleSegment {
        segment: &'b [u8],
    },
    MultipleSegments {
        message: &'b [u8],
    },
}
Expand description

Segments read from a buffer, useful for when you have the message in a buffer and don’t want the extra copy of read_message.

NoAllocSliceSegments is similar to crate::serialize::SliceSegments but optimized for low memory embedded environment. It does not do heap allocations and consumes only one fat pointer worth of memory.

Performance considerations

Due to lack of heap allocations, NoAllocSliceSegments does not cache segments offset and length and has to parse message header every time NoAllocSliceSegments::get_segment is called. The parsing has O(N) complexity where N is total number of segments in the message. NoAllocSliceSegments has optimization for single segment messages: if message has only one segment, it will be parsed only once during creation and no parsing will be required on get_segment calls

Variants

SingleSegment

Fields

segment: &'b [u8]

MultipleSegments

Fields

message: &'b [u8]

Implementations

Reads a serialized message (including a segment table) from a buffer and takes ownership, without copying. The slice is allowed to extend beyond the end of the message. On success, updates slice to point to the remaining bytes beyond the end of the message.

ALIGNMENT: If the “unaligned” feature is enabled, then there are no alignment requirements on buffer. Otherwise, buffer must be 8-byte aligned (attempts to read the message will trigger errors).

Trait Implementations

Gets the segment with index idx. Returns None if idx is out of range. Read more

Gets the number of segments.

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.

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.