Skip to main content

MutInPlaceValue

Trait MutInPlaceValue 

Source
pub trait MutInPlaceValue: Value {
    type BaseRefType: Debug + ?Sized;

    // Required methods
    fn initialize(data: &mut [u8]);
    fn from_bytes_mut(data: &mut [u8]) -> &mut Self::BaseRefType;
}
Expand description

Implementing this trait indicates that the type can be mutated in-place as a &mut u8. This enables the .insert_reserve() method on Table

Required Associated Types§

Source

type BaseRefType: Debug + ?Sized

The base type such that &mut u8 can be safely transmuted to &mut BaseRefType

Required Methods§

Source

fn initialize(data: &mut [u8])

Initialize data to a valid value. This method will be called (at some point, not necessarily immediately) before from_bytes_mut() is called on a slice.

Note: There must exist a value v of type Self such that as_bytes(&v) equals data.

Source

fn from_bytes_mut(data: &mut [u8]) -> &mut Self::BaseRefType

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl MutInPlaceValue for &[u8]

Source§

type BaseRefType = [u8]

Source§

fn initialize(_data: &mut [u8])

Source§

fn from_bytes_mut(data: &mut [u8]) -> &mut Self::BaseRefType

Implementors§