[][src]Trait rkyv::Write

pub trait Write {
    type Error: 'static;
    pub fn pos(&self) -> usize;
pub fn write(&mut self, bytes: &[u8]) -> Result<(), Self::Error>; pub fn pad(&mut self, mut padding: usize) -> Result<(), Self::Error> { ... }
pub fn align(&mut self, align: usize) -> Result<usize, Self::Error> { ... }
pub fn align_for<T>(&mut self) -> Result<usize, Self::Error> { ... }
pub unsafe fn resolve_aligned<T: ?Sized, R: Resolve<T>>(
        &mut self,
        value: &T,
        resolver: R
    ) -> Result<usize, Self::Error> { ... }
pub fn archive<T: Archive>(
        &mut self,
        value: &T
    ) -> Result<usize, Self::Error> { ... }
pub fn archive_ref<T: ArchiveRef + ?Sized>(
        &mut self,
        value: &T
    ) -> Result<usize, Self::Error> { ... } }

A #![no_std] compliant writer that knows where it is.

A type that is io::Write can be wrapped in an ArchiveWriter to equip it with Write. It's important that the memory for archived objects is properly aligned before attempting to read objects out of it, use the Aligned wrapper if it's appropriate.

Associated Types

type Error: 'static[src]

The errors that may occur while writing.

Loading content...

Required methods

pub fn pos(&self) -> usize[src]

Returns the current position of the writer.

pub fn write(&mut self, bytes: &[u8]) -> Result<(), Self::Error>[src]

Attempts to write the given bytes to the writer.

Loading content...

Provided methods

pub fn pad(&mut self, mut padding: usize) -> Result<(), Self::Error>[src]

Advances the given number of bytes as padding.

pub fn align(&mut self, align: usize) -> Result<usize, Self::Error>[src]

Aligns the position of the writer to the given alignment.

pub fn align_for<T>(&mut self) -> Result<usize, Self::Error>[src]

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

pub unsafe fn resolve_aligned<T: ?Sized, R: Resolve<T>>(
    &mut self,
    value: &T,
    resolver: R
) -> Result<usize, Self::Error>
[src]

Resolves the given resolver and writes its archived type, returning the position of the written archived type.

Safety

This is only safe to call when the writer is already aligned for the archived version of the given type.

pub fn archive<T: Archive>(&mut self, value: &T) -> Result<usize, Self::Error>[src]

Archives the given object and returns the position it was archived at.

pub fn archive_ref<T: ArchiveRef + ?Sized>(
    &mut self,
    value: &T
) -> Result<usize, Self::Error>
[src]

Archives a reference to the given object and returns the position it was archived at.

Loading content...

Implementors

impl<T: AsRef<[u8]> + AsMut<[u8]>> Write for ArchiveBuffer<T>[src]

type Error = ArchiveBufferError

impl<W: Write> Write for ArchiveWriter<W>[src]

type Error = Error

Loading content...