pub struct ArchiveSerializer { /* private fields */ }Available on crate feature
archive only.Expand description
Serializer that produces the flat archive payload.
Implementations§
Source§impl ArchiveSerializer
impl ArchiveSerializer
Sourcepub fn write_bool(&mut self, value: bool)
pub fn write_bool(&mut self, value: bool)
Writes a fixed-width bool.
Sourcepub fn reserve_ptr(&mut self) -> usize
pub fn reserve_ptr(&mut self) -> usize
Reserves a 4-byte placeholder for a RelPtr and returns the absolute
position of the placeholder.
Sourcepub fn align_to(&mut self, align: usize)
pub fn align_to(&mut self, align: usize)
Pads the output with zero bytes until the length is a multiple of
align.
The archived mirrors are #[repr(C)] structs, so the writer inserts
the same padding between fields (and before Vec<T> element arrays)
that the C ABI does. A zero align would divide by zero; the derive
only ever passes real type alignments (1, 2, 4, or 8).
Sourcepub fn write_string_at(
&mut self,
field_pos: usize,
value: &str,
) -> Result<(), String>
pub fn write_string_at( &mut self, field_pos: usize, value: &str, ) -> Result<(), String>
Appends a String body and patches the placeholder at field_pos.
Sourcepub fn write_vec_at<T: Pod>(
&mut self,
field_pos: usize,
values: &[T],
) -> Result<(), String>
pub fn write_vec_at<T: Pod>( &mut self, field_pos: usize, values: &[T], ) -> Result<(), String>
Appends a Vec<T> body (count + alignment padding + elements) and
patches the placeholder.
Trait Implementations§
Auto Trait Implementations§
impl Forget for ArchiveSerializer
impl Freeze for ArchiveSerializer
impl RefUnwindSafe for ArchiveSerializer
impl Send for ArchiveSerializer
impl Sync for ArchiveSerializer
impl Unpin for ArchiveSerializer
impl UnsafeUnpin for ArchiveSerializer
impl UnwindSafe for ArchiveSerializer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more