pub struct SliceMutWriter<'a> { /* private fields */ }Expand description
A writer into a slice.
This is typically created by using a mutable slice as a writer through
the IntoWriter trait.
§Examples
use musli::writer::{IntoWriter, Writer};
use musli::context;
let mut buffer = [0u8; 10];
let mut writer = buffer.as_mut_slice().into_writer();
let cx = context::new();
writer.write_bytes(&cx, b"Hello")?;
let remaining = writer.finish(&cx)?;
assert_eq!(&buffer[..5], b"Hello");
assert_eq!(remaining, 5); // 5 bytes remaining in the 10-byte bufferTrait Implementations§
Source§impl<'a> Writer for SliceMutWriter<'a>
impl<'a> Writer for SliceMutWriter<'a>
Source§type Mut<'this> = &'this mut SliceMutWriter<'a>
where
Self: 'this
type Mut<'this> = &'this mut SliceMutWriter<'a> where Self: 'this
Reborrowed type. Read more
Source§fn finish<C>(&mut self, _: C) -> Result<Self::Ok, C::Error>where
C: Context,
fn finish<C>(&mut self, _: C) -> Result<Self::Ok, C::Error>where
C: Context,
Finalize the writer and return the output.
Source§fn borrow_mut(&mut self) -> Self::Mut<'_>
fn borrow_mut(&mut self) -> Self::Mut<'_>
Reborrow the current type. Read more
Source§fn extend<C>(
&mut self,
cx: C,
buffer: Vec<u8, C::Allocator>,
) -> Result<(), C::Error>where
C: Context,
fn extend<C>(
&mut self,
cx: C,
buffer: Vec<u8, C::Allocator>,
) -> Result<(), C::Error>where
C: Context,
Write a buffer to the current writer. Read more
Auto Trait Implementations§
impl<'a> Freeze for SliceMutWriter<'a>
impl<'a> RefUnwindSafe for SliceMutWriter<'a>
impl<'a> !Send for SliceMutWriter<'a>
impl<'a> !Sync for SliceMutWriter<'a>
impl<'a> Unpin for SliceMutWriter<'a>
impl<'a> UnsafeUnpin for SliceMutWriter<'a>
impl<'a> !UnwindSafe for SliceMutWriter<'a>
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