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§
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] ⓘ
Sourceunsafe fn as_mut_bytes(&mut self) -> &mut [u8] ⓘ
unsafe fn as_mut_bytes(&mut self) -> &mut [u8] ⓘ
§Safety
Modification of returned bytes must not make self invalid.
Sourcefn new_in_place<I: Emplacer<Self>>(
bytes: &mut [u8],
emplacer: I,
) -> Result<&mut Self, Error>
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.
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.