Skip to main content

IoBuf

Trait IoBuf 

Source
pub unsafe trait IoBuf:
    Unpin
    + Send
    + '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>) -> OwnedSlice<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>) -> OwnedSlice<Self>
where Self: Sized,

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

Dyn Compatibility§

This trait is dyn compatible.

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

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 Bytes

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<T: Unpin + Send + 'static> IoBuf for Buffer<T>

Source§

fn read_ptr(&self) -> *const u8

Source§

fn bytes_init(&self) -> usize

Source§

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

Source§

impl<const A: usize> IoBuf for ConstByteBuffer<A>

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§