Skip to main content

Segment

Trait Segment 

Source
pub trait Segment {
    // Required methods
    fn number_of_bytes(&self) -> usize;
    fn empty() -> Self;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

Some sort of segment that knows its length (in bytes). It’s used for constructing binaries/strings efficiently (knowing the entire length in advance to avoid re-allocations).

Required Methods§

Source

fn number_of_bytes(&self) -> usize

The number of bytes in this segment.

Source

fn empty() -> Self

Constructs an empty-segment (number_of_bytes is 0).

Provided Methods§

Source

fn is_empty(&self) -> bool

Same as number_of_bytes==0.

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§

Source§

impl<'a, TAnyBin> Segment for BinSegment<'a, TAnyBin>
where TAnyBin: AnyBin,

Source§

impl<'a, TBin: AnyBin> Segment for StrSegment<'a, TBin>