tendril::fmt

Trait Slice

Source
pub unsafe trait Slice {
    // Required methods
    fn as_bytes(&self) -> &[u8] ;
    unsafe fn from_bytes(x: &[u8]) -> &Self;
    unsafe fn from_mut_bytes(x: &mut [u8]) -> &mut Self;
}
Expand description

Indicates a Rust slice type that is represented in memory as bytes.

Required Methods§

Source

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

Access the raw bytes of the slice.

Source

unsafe fn from_bytes(x: &[u8]) -> &Self

Convert a byte slice to this kind of slice.

You may assume the buffer is already validated for Format.

Source

unsafe fn from_mut_bytes(x: &mut [u8]) -> &mut Self

Convert a byte slice to this kind of slice.

You may assume the buffer is already validated for Format.

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 Slice for str

Source§

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

Source§

unsafe fn from_bytes(x: &[u8]) -> &str

Source§

unsafe fn from_mut_bytes(x: &mut [u8]) -> &mut str

Source§

impl Slice for [u8]

Source§

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

Source§

unsafe fn from_bytes(x: &[u8]) -> &[u8]

Source§

unsafe fn from_mut_bytes(x: &mut [u8]) -> &mut [u8]

Implementors§