pub trait CustomBorrow<'a, T, L> {
// Required methods
fn custom_borrow(&'a mut self, layout: L) -> T;
unsafe fn extract_layout(&self) -> L;
}
Expand description
A trait that allows for custom implementation of borrow
given the necessary information
This is useful for record structs that have dynamic size
Required Methods§
fn custom_borrow(&'a mut self, layout: L) -> T
Sourceunsafe fn extract_layout(&self) -> L
unsafe fn extract_layout(&self) -> L
Given &self
as a valid starting pointer of a reference that has already been previously
allocated and written to, extracts and returns the corresponding layout.
This must work even if T
is not sized.
§Safety
&self
must be a valid starting pointer on whichcustom_borrow
has already been called- The data underlying
&self
has already been written to and is self-describing, so layout can be extracted
Implementations on Foreign Types§
Source§impl<'a> CustomBorrow<'a, AccessRecordMut<'a>, AccessLayout> for [u8]
impl<'a> CustomBorrow<'a, AccessRecordMut<'a>, AccessLayout> for [u8]
fn custom_borrow(&'a mut self, layout: AccessLayout) -> AccessRecordMut<'a>
unsafe fn extract_layout(&self) -> AccessLayout
Source§impl<'a, T: Sized, L: Default> CustomBorrow<'a, &'a mut T, L> for [u8]
If a struct implements BorrowMut<T>
, then the same implementation can be used for
CustomBorrow::custom_borrow
with any layout
impl<'a, T: Sized, L: Default> CustomBorrow<'a, &'a mut T, L> for [u8]
If a struct implements BorrowMut<T>
, then the same implementation can be used for
CustomBorrow::custom_borrow
with any layout