Skip to main content

Buffer

Trait Buffer 

Source
pub unsafe trait Buffer: Sized {
    // Required methods
    fn as_bytes(&self) -> &[u8] ;
    fn into_bytes(self) -> Vec<u8> ;
}
Expand description

Trusted byte buffer type.

§Safety

Any interior mutability in the buffer type must not affect the as_bytes and into_bytes methods. In other words, as long as self is borrowed immutably those functions must always return the same result.

Required Methods§

Source

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

Borrows the buffer bytes.

Source

fn into_bytes(self) -> Vec<u8>

Turns this buffer into a byte array.

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.

Implementations on Foreign Types§

Source§

impl Buffer for String

Available on crate feature std only.
Source§

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

Source§

fn into_bytes(self) -> Vec<u8>

Source§

impl Buffer for Vec<u8>

Available on crate feature std only.
Source§

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

Source§

fn into_bytes(self) -> Vec<u8>

Implementors§