pub struct IoWriter<W> { /* private fields */ }Expand description
Wraps a type that implements io::Write and equips it
with Writer.
§Examples
use rkyv::rancor::{Error, Strategy};
let mut io_writer = IoWriter::new(Vec::new());
// In most cases, calling a method like `serialize` will wrap the writer in
// a Strategy for us.
let mut writer = Strategy::<_, Error>::wrap(&mut io_writer);
assert_eq!(writer.pos(), 0);
writer.write(&[0u8, 1u8, 2u8, 3u8]);
assert_eq!(writer.pos(), 4);
let buf = io_writer.into_inner();
assert_eq!(buf.len(), 4);
assert_eq!(buf, vec![0u8, 1u8, 2u8, 3u8]);Implementations§
Source§impl<W> IoWriter<W>
impl<W> IoWriter<W>
Sourcepub fn with_pos(inner: W, pos: usize) -> Self
pub fn with_pos(inner: W, pos: usize) -> Self
Creates a new serializer from a writer, and assumes that the underlying writer is currently at the given position.
Sourcepub fn into_inner(self) -> W
pub fn into_inner(self) -> W
Consumes the serializer and returns the internal writer used to create it.
Trait Implementations§
Auto Trait Implementations§
impl<W> Freeze for IoWriter<W>where
W: Freeze,
impl<W> RefUnwindSafe for IoWriter<W>where
W: RefUnwindSafe,
impl<W> Send for IoWriter<W>where
W: Send,
impl<W> Sync for IoWriter<W>where
W: Sync,
impl<W> Unpin for IoWriter<W>where
W: Unpin,
impl<W> UnsafeUnpin for IoWriter<W>where
W: UnsafeUnpin,
impl<W> UnwindSafe for IoWriter<W>where
W: UnwindSafe,
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Returns the layout of the type.
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Returns whether the given value has been niched. Read more
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
Writes data to
out indicating that a T is niched.Source§impl<T, E> WriterExt<E> for T
impl<T, E> WriterExt<E> for T
Source§fn pad(&mut self, padding: usize) -> Result<(), E>
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>
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>
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>
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. Read more
Source§unsafe fn resolve_unsized_aligned<T: ArchiveUnsized + ?Sized>(
&mut self,
value: &T,
to: usize,
) -> Result<usize, E>
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. Read more