Skip to main content

AlignedBuffer

Trait AlignedBuffer 

Source
pub trait AlignedBuffer:
    Sealed
    + Deref<Target = [u8]>
    + StableDeref
    + Debug
    + Send
    + Sync
    + 'static {
    type Alignment: Alignment;

    // Required methods
    fn len(&self) -> u32;
    fn is_empty(&self) -> bool;
    fn offset(&self) -> u32;
    fn allocation_alignment(&self) -> usize;
    fn into_shared(self) -> SharedAlignedBuffer<Self::Alignment>;
}
Expand description

Common interface of OwnedAlignedBuffer and SharedAlignedBuffer.

Contents don’t move when the buffer is moved, so a buffer can be moved into an operation that accesses its memory, like asynchronous I/O, which then returns it back.

Required Associated Types§

Source

type Alignment: Alignment

Alignment of the contents

Required Methods§

Source

fn len(&self) -> u32

Length of the contents

Source

fn is_empty(&self) -> bool

Whether the contents are empty

Source

fn offset(&self) -> u32

Offset of the contents from the beginning of the data region of the allocation

Source

fn allocation_alignment(&self) -> usize

Alignment of the allocation in bytes, see OwnedAlignedBuffer::allocation_alignment()

Source

fn into_shared(self) -> SharedAlignedBuffer<Self::Alignment>

Convert into shared buffer, which reuses the allocation

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§