FlatUnsized

Trait FlatUnsized 

Source
pub unsafe trait FlatUnsized: FlatBase {
    type AlignAs: Sized + Send + Sync;

    // Required methods
    unsafe fn ptr_from_bytes(bytes: *mut [u8]) -> *mut Self;
    unsafe fn ptr_to_bytes(this: *mut Self) -> *mut [u8];

    // Provided methods
    unsafe fn from_bytes_unchecked(bytes: &[u8]) -> &Self { ... }
    unsafe fn from_mut_bytes_unchecked(bytes: &mut [u8]) -> &mut Self { ... }
    fn as_bytes(&self) -> &[u8]  { ... }
    unsafe fn as_mut_bytes(&mut self) -> &mut [u8]  { ... }
    fn new_in_place<I: Emplacer<Self>>(
        bytes: &mut [u8],
        emplacer: I,
    ) -> Result<&mut Self, Error> { ... }
    fn assign_in_place<I: Emplacer<Self>>(
        &mut self,
        emplacer: I,
    ) -> Result<&mut Self, Error> { ... }
}
Expand description

Dynamically-sized flat type. Like ?Sized but for Flat.

For now has to be implemented for all Flat types because there is no mutually exclusive traits in Rust yet.

Required Associated Types§

Source

type AlignAs: Sized + Send + Sync

Sized type that has the same alignment as Self.

Required Methods§

Source

unsafe fn ptr_from_bytes(bytes: *mut [u8]) -> *mut Self

Source

unsafe fn ptr_to_bytes(this: *mut Self) -> *mut [u8]

Provided Methods§

Source

unsafe fn from_bytes_unchecked(bytes: &[u8]) -> &Self

Source

unsafe fn from_mut_bytes_unchecked(bytes: &mut [u8]) -> &mut Self

Source

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

Source

unsafe fn as_mut_bytes(&mut self) -> &mut [u8]

§Safety

Modification of returned bytes must not make self invalid.

Source

fn new_in_place<I: Emplacer<Self>>( bytes: &mut [u8], emplacer: I, ) -> Result<&mut Self, Error>

Create a new instance of Self initializing raw memory into default state of Self.

Source

fn assign_in_place<I: Emplacer<Self>>( &mut self, emplacer: I, ) -> Result<&mut Self, Error>

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.

Implementors§

Source§

impl<T, L> FlatUnsized for FlatVec<T, L>
where T: Flat + Sized, L: Flat + Length,

Source§

impl<T: FlatSized> FlatUnsized for T