[−][src]Struct abin::spi::FnTable
The function table to be implemented for Bin
types. This is only required if you
implement your own binary type.
Fields
drop: Option<fn(bin: &mut Bin)>
Drop function. It's None
if dropping is not required.
as_slice: Option<fn(bin: &Bin) -> &[u8]>
Returns a slice of this binary.
It's allowed to be None
if this binary is always empty (constant).
is_empty: Option<fn(bin: &Bin) -> bool>
True if this binary has a length of 0.
It's allowed to be None
if this binary is always empty (constant).
clone: fn(bin: &Bin) -> Bin
Clones this type.
IMPORTANT: It's required to return a sync binary if self is also a sync binary (this is not checked by the compiler, it's in the responsibility of the implementer).
into_vec: fn(bin: Bin) -> Vec<u8>
Converts this binary into a vector; Tries to avoid allocation/memory-copy whenever possible.
slice: fn(bin: &Bin, start: usize, end_excluded: usize) -> Option<Bin>
Returns a slice of the given binary. Returns None
if the given range is out of bounds.
Important: If bin
is synchronized, the returned Bin
MUST be synchronized too.
convert_into_un_sync: Option<fn(bin: Bin) -> Bin>
Returns an un-synchronized version (not just a view - if there's an un-synchronized version).
This is allowed to be None
if:
- This is already the un-synchronized version.
- There's no un-synchronized version.
convert_into_sync: Option<fn(bin: Bin) -> Bin>
Returns a synchronized version.
This is allowed to be None
if: This is already the synchronized version. IMPORTANT:
IT IS NEVER allowed to return None
here if this is not the synchronized version (this
can't be checked by the compiler; it's in the responsibility of the implementer).
try_re_integrate: Option<TryReIntegrateFn>
Tries to re-integrate the given slice into the given binary.
Details: If the given binary is a slice of the given binary, it returns a re-integrated
version. Example: Say bin
is a reference-counted binary from address 150 to 220
(length 70) and the given slice points to memory address 170 and has a length of 30,
this function returns a slice of the reference-counted binary (start 20, length 30).
This is None
if the binary type does not support re-integration altogether. This
function returns None
if the given slice cannot be re-integrated. This method usually
makes only sense for reference-counted binaries or static binaries. This is purely an
optimization - it's valid to always return None
here.
IMPORTANT: If bin
is a synchronized binary, the returned binary has to be
synchronized too.
Auto Trait Implementations
impl RefUnwindSafe for FnTable
impl Send for FnTable
impl Sync for FnTable
impl Unpin for FnTable
impl UnwindSafe for FnTable
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,