Trait abomonation::Abomonation
[−]
[src]
pub trait Abomonation { unsafe fn entomb<W: Write>(&self, _write: &mut W) -> IOResult<()> { ... } unsafe fn exhume<'a, 'b>(
&'a mut self,
bytes: &'b mut [u8]
) -> Option<&'b mut [u8]> { ... } fn extent(&self) -> usize { ... } }
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<W: Write>(&self, _write: &mut W) -> IOResult<()>
Write any additional information about &self
beyond its binary representation.
Most commonly this is owned data on the other end of pointers in &self
. The return value
reports any failures in writing to write
.
unsafe fn exhume<'a, 'b>(
&'a mut self,
bytes: &'b mut [u8]
) -> Option<&'b mut [u8]>
&'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
.
fn extent(&self) -> usize
Reports the number of further bytes required to entomb self
.