Writer

Struct Writer 

Source
pub struct Writer<'w, B: ?Sized> { /* private fields */ }
Expand description

A structure wrapping a mutable pointer to a buffer

Implementations§

Source§

impl<B: ?Sized> Writer<'_, B>

Source

pub fn position(&self) -> usize

Accessor for the writer position

Source§

impl<'w> Writer<'w, [u8]>

Source

pub fn from_slice(slice: &'w mut [u8]) -> Self

Create a new writer from a mutable byte slice

Source

pub fn from_slice_position(slice: &'w mut [u8], pos: usize) -> Self

Create a new writer from a mutable byte slice, skipping a prefix

Source§

impl<'w> Writer<'w, Vec<u8>>

Source

pub fn from_vec(vec: &'w mut Vec<u8>) -> Self

Available on crate feature alloc only.

Create a new writer from a mutable Vec pointer

Source

pub fn from_vec_skip(vec: &'w mut Vec<u8>, pos: usize) -> Self

Available on crate feature alloc only.

Create a new writer from a mutable Vec pointer, skipping a prefix

Source§

impl<'b, B: ?Sized> Writer<'b, B>

Source

pub fn from_buffer(buf: &'b mut B) -> Writer<'b, B>

Create a new writer from a reference to a buffer implementation

Trait Implementations§

Source§

impl AsMut<[u8]> for Writer<'_, [u8]>

Source§

fn as_mut(&mut self) -> &mut [u8]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<B: ResizeBuffer + ?Sized> AsMut<[u8]> for Writer<'_, B>

Source§

fn as_mut(&mut self) -> &mut [u8]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<[u8]> for Writer<'_, [u8]>

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<B: ResizeBuffer + ?Sized> AsRef<[u8]> for Writer<'_, B>

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'w, B: Debug + ?Sized> Debug for Writer<'w, B>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl ResizeBuffer for Writer<'_, [u8]>

Source§

fn buffer_insert(&mut self, pos: usize, data: &[u8]) -> Result<(), Error>

Insert a slice at the given position in the buffer
Source§

fn buffer_remove(&mut self, range: Range<usize>) -> Result<(), Error>

Remove an exclusive range from the buffer
Source§

fn buffer_resize(&mut self, len: usize) -> Result<(), Error>

Resize the buffer, truncating or padding it with zeroes
Source§

fn buffer_extend(&mut self, len: usize) -> Result<&mut [u8], Error>

Extend the buffer with len bytes of zeroes and return a mutable reference to the slice
Source§

impl<B: ResizeBuffer + ?Sized> ResizeBuffer for Writer<'_, B>

Source§

fn buffer_insert(&mut self, pos: usize, data: &[u8]) -> Result<(), Error>

Insert a slice at the given position in the buffer
Source§

fn buffer_remove(&mut self, range: Range<usize>) -> Result<(), Error>

Remove an exclusive range from the buffer
Source§

fn buffer_resize(&mut self, len: usize) -> Result<(), Error>

Resize the buffer, truncating or padding it with zeroes
Source§

fn buffer_extend(&mut self, len: usize) -> Result<&mut [u8], Error>

Extend the buffer with len bytes of zeroes and return a mutable reference to the slice
Source§

impl<'b, B: ?Sized> Write for Writer<'b, B>
where Writer<'b, B>: WriteBuffer,

Source§

fn write_str(&mut self, s: &str) -> Result

Writes a string slice into this writer, returning whether the write succeeded. Read more
1.1.0 · Source§

fn write_char(&mut self, c: char) -> Result<(), Error>

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more
Source§

impl WriteBuffer for Writer<'_, [u8]>

Source§

fn buffer_write(&mut self, data: &[u8]) -> Result<(), Error>

Append a slice to the buffer
Source§

impl<B: WriteBuffer + ?Sized> WriteBuffer for Writer<'_, B>

Source§

fn buffer_write(&mut self, data: &[u8]) -> Result<(), Error>

Append a slice to the buffer

Auto Trait Implementations§

§

impl<'w, B> Freeze for Writer<'w, B>
where B: ?Sized,

§

impl<'w, B> RefUnwindSafe for Writer<'w, B>
where B: RefUnwindSafe + ?Sized,

§

impl<'w, B> Send for Writer<'w, B>
where B: Send + ?Sized,

§

impl<'w, B> Sync for Writer<'w, B>
where B: Sync + ?Sized,

§

impl<'w, B> Unpin for Writer<'w, B>
where B: ?Sized,

§

impl<'w, B> !UnwindSafe for Writer<'w, B>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V