Trait abomonation::Abomonation
[−]
[src]
pub trait Abomonation { unsafe fn entomb(&self, _writer: &mut Vec<u8>) { ... } unsafe fn embalm(&mut self) { ... } unsafe fn exhume<'a, 'b>(&'a mut self, bytes: &'b mut [u8]) -> Option<&'b mut [u8]> { ... } }
Abomonation provides methods to serialize any heap data the implementor owns.
The default implementations for Abomonation's methods are all empty. Many types have no owned data to transcribe. Some do, however, and need to carefully implement these unsafe methods.
Safety
Abomonation has no safe methods. Please do not call them. They should be called only by
encode
and decode
, each of which impose restrictions on ownership and lifetime of the data
they take as input and return as output.
If you are concerned about safety, it may be best to avoid Abomonation all together. It does several things that may be undefined behavior, depending on how undefined behavior is defined.
Provided Methods
unsafe fn entomb(&self, _writer: &mut Vec<u8>)
Write any additional information about &self
beyond its binary representation.
Most commonly this is owned data on the other end of pointers in &self
.
unsafe fn embalm(&mut self)
Perform any final edits before committing &mut self
. Importantly, this method should only
manipulate the fields of self
; any owned memory may not be valid.
Most commonly this overwrites pointers whose values should not be serialized.
unsafe fn exhume<'a, 'b>(&'a mut self, bytes: &'b mut [u8]) -> Option<&'b mut [u8]>
Recover any information for &mut self
not evident from its binary representation.
Most commonly this populates pointers with valid references into bytes
.
Implementors
impl Abomonation for u8
impl Abomonation for u16
impl Abomonation for u32
impl Abomonation for u64
impl Abomonation for usize
impl Abomonation for i8
impl Abomonation for i16
impl Abomonation for i32
impl Abomonation for i64
impl Abomonation for isize
impl Abomonation for f32
impl Abomonation for f64
impl Abomonation for bool
impl Abomonation for ()
impl Abomonation for char
impl<T: Abomonation> Abomonation for Option<T>
impl<A: Abomonation> Abomonation for (A,)
impl<A: Abomonation, B: Abomonation> Abomonation for (A, B)
impl<A: Abomonation, B: Abomonation, C: Abomonation> Abomonation for (A, B, C)
impl<A: Abomonation, B: Abomonation, C: Abomonation, D: Abomonation> Abomonation for (A, B, C, D)
impl<A: Abomonation, B: Abomonation, C: Abomonation, D: Abomonation, E: Abomonation> Abomonation for (A, B, C, D, E)
impl<A: Abomonation, B: Abomonation, C: Abomonation, D: Abomonation, E: Abomonation, F: Abomonation> Abomonation for (A, B, C, D, E, F)
impl<A: Abomonation, B: Abomonation, C: Abomonation, D: Abomonation, E: Abomonation, F: Abomonation, G: Abomonation> Abomonation for (A, B, C, D, E, F, G)
impl<A: Abomonation, B: Abomonation, C: Abomonation, D: Abomonation, E: Abomonation, F: Abomonation, G: Abomonation, H: Abomonation> Abomonation for (A, B, C, D, E, F, G, H)
impl<A: Abomonation, B: Abomonation, C: Abomonation, D: Abomonation, E: Abomonation, F: Abomonation, G: Abomonation, H: Abomonation, I: Abomonation> Abomonation for (A, B, C, D, E, F, G, H, I)
impl<A: Abomonation, B: Abomonation, C: Abomonation, D: Abomonation, E: Abomonation, F: Abomonation, G: Abomonation, H: Abomonation, I: Abomonation, J: Abomonation> Abomonation for (A, B, C, D, E, F, G, H, I, J)
impl Abomonation for String
impl<'c> Abomonation for &'c str
impl<T: Abomonation> Abomonation for Vec<T>
impl<'c, T: Abomonation> Abomonation for &'c [T]
impl<T: Abomonation> Abomonation for Box<T>