Trait vortex_io::IoBuf

source ·
pub unsafe trait IoBuf: Unpin + 'static {
    // Required methods
    fn read_ptr(&self) -> *const u8;
    fn bytes_init(&self) -> usize;
    fn as_slice(&self) -> &[u8] ;

    // Provided method
    fn slice_owned(self, range: Range<usize>) -> Slice<Self>
       where Self: Sized { ... }
}
Expand description

Trait for types that can provide a readonly byte buffer interface to I/O frameworks.

§Safety

The type must support contiguous raw memory access via pointer, such as Vec or [u8].

Required Methods§

source

fn read_ptr(&self) -> *const u8

Returns a raw pointer to the vector’s buffer.

source

fn bytes_init(&self) -> usize

Number of initialized bytes.

source

fn as_slice(&self) -> &[u8]

Access the buffer as a byte slice

Provided Methods§

source

fn slice_owned(self, range: Range<usize>) -> Slice<Self>
where Self: Sized,

Access the buffer as a byte slice with begin and end indices

Implementations on Foreign Types§

source§

impl IoBuf for &'static [u8]

source§

fn read_ptr(&self) -> *const u8

source§

fn bytes_init(&self) -> usize

source§

fn as_slice(&self) -> &[u8]

source§

impl IoBuf for Vec<u8>

source§

fn read_ptr(&self) -> *const u8

source§

fn bytes_init(&self) -> usize

source§

fn as_slice(&self) -> &[u8]

source§

impl IoBuf for Buffer

source§

fn read_ptr(&self) -> *const u8

source§

fn bytes_init(&self) -> usize

source§

fn as_slice(&self) -> &[u8]

source§

impl<const N: usize> IoBuf for [u8; N]

source§

fn read_ptr(&self) -> *const u8

source§

fn bytes_init(&self) -> usize

source§

fn as_slice(&self) -> &[u8]

Implementors§

source§

impl<T: IoBuf> IoBuf for Slice<T>