[go: up one dir, main page]

WriterExt

Trait WriterExt 

Source
pub trait WriterExt<E>: Writer<E> {
    // Provided methods
    fn pad(&mut self, padding: usize) -> Result<(), E> { ... }
    fn align(&mut self, align: usize) -> Result<usize, E> { ... }
    fn align_for<T>(&mut self) -> Result<usize, E> { ... }
    unsafe fn resolve_aligned<T: Archive + ?Sized>(
        &mut self,
        value: &T,
        resolver: T::Resolver,
    ) -> Result<usize, E> { ... }
    unsafe fn resolve_unsized_aligned<T: ArchiveUnsized + ?Sized>(
        &mut self,
        value: &T,
        to: usize,
    ) -> Result<usize, E> { ... }
}
Expand description

Helper methods for Writer.

Provided Methods§

Source

fn pad(&mut self, padding: usize) -> Result<(), E>

Advances the given number of bytes as padding.

Source

fn align(&mut self, align: usize) -> Result<usize, E>

Aligns the position of the serializer to the given alignment.

Source

fn align_for<T>(&mut self) -> Result<usize, E>

Aligns the position of the serializer to be suitable to write the given type.

Source

unsafe fn resolve_aligned<T: Archive + ?Sized>( &mut self, value: &T, resolver: T::Resolver, ) -> Result<usize, E>

Resolves the given value with its resolver and writes the archived type.

Returns the position of the written archived type.

§Safety
  • resolver must be the result of serializing value
  • The serializer must be aligned for a T::Archived
Source

unsafe fn resolve_unsized_aligned<T: ArchiveUnsized + ?Sized>( &mut self, value: &T, to: usize, ) -> Result<usize, E>

Resolves the given reference with its resolver and writes the archived reference.

Returns the position of the written archived RelPtr.

§Safety

The serializer must be aligned for a RelPtr<T::Archived>.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T, E> WriterExt<E> for T
where T: Writer<E> + ?Sized,