Module octseq::octets

source ·
Expand description

Octets Sequences

An octets sequence – or just octets for short – is a variable length sequence of bytes. In their most simple form, any type that implements AsRef<[u8]> can serve as octets. However, in some cases additional functionality is required.

The trait Octets allows taking a sub-sequence, called a ‘range’, out of the octets in the cheapest way possible. For most types, ranges will be octet slices &[u8] but some shareable types (most notably bytes::Bytes) allow ranges to be owned values, thus avoiding the lifetime limitations a slice would bring. Therefore, Octets allows defining the type of a range as an associated type.


  • A type representing an octets sequence.
  • Convert a type from one octets type to another.
  • Convert a type from one octets type to another.

Type Definitions

  • A octets vector that doesn’t allocate for small sizes.