Trait zerocopy::byte_slice::IntoByteSlice

source ·
pub unsafe trait IntoByteSlice<'a>: ByteSlice {
    // Required method
    fn into_byte_slice(self) -> &'a [u8];
}
Expand description

A ByteSlice that conveys no ownership, and so can be converted into a byte slice.

Some ByteSlice types (notably, the standard library’s Ref type) convey ownership, and so they cannot soundly be moved by-value into a byte slice type (&[u8]). Some methods in this crate’s API (such as Ref::into_ref) are only compatible with ByteSlice types without these ownership semantics.

Required Methods§

source

fn into_byte_slice(self) -> &'a [u8]

Coverts self into a &[u8].

§Safety

The returned reference has the same address and length as self.deref() and self.deref_mut().

Note that, combined with the safety invariant on ByteSlice, this safety invariant implies that the returned reference is “stable” in the sense described in the ByteSlice docs.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<'a> IntoByteSlice<'a> for &'a [u8]

source§

fn into_byte_slice(self) -> &'a [u8]

source§

impl<'a> IntoByteSlice<'a> for &'a mut [u8]

source§

fn into_byte_slice(self) -> &'a [u8]

Implementors§