Skip to main content

Writer

Struct Writer 

Source
pub struct Writer<'cx> { /* private fields */ }
Expand description

Where values are written: bytes, the first value that couldn’t be, and the context they are written in.

Implementations§

Source§

impl Writer<'_>

Source

pub fn new() -> Self

Source

pub fn with_capacity(capacity: usize) -> Self

Source

pub fn from_vec(bytes: Vec<u8>) -> Self

A writer that appends to bytes.

Source

pub fn with_context<'c>(self, context: &'c mut (dyn Context + 'c)) -> Writer<'c>

This writer, writing in context.

Source

pub fn context<T: Any>(&mut self) -> Option<&T>

The context’s part of type T, if it has one.

Source

pub fn context_mut<T: Any>(&mut self) -> Option<&mut T>

The context’s part of type T, to change, if it has one.

Source

pub fn push(&mut self, byte: u8)

Source

pub fn extend_from_slice(&mut self, bytes: &[u8])

Source

pub fn fail(&mut self, error: String)

Records that a value can’t be written; the first such error is what Writer::finish returns.

Source

pub fn finish(self) -> Result<Vec<u8>, String>

The bytes written, or why a value couldn’t be.

Trait Implementations§

Source§

impl<'cx> Default for Writer<'cx>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'cx> !RefUnwindSafe for Writer<'cx>

§

impl<'cx> !Send for Writer<'cx>

§

impl<'cx> !Sync for Writer<'cx>

§

impl<'cx> !UnwindSafe for Writer<'cx>

§

impl<'cx> Forget for Writer<'cx>

§

impl<'cx> Freeze for Writer<'cx>
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, &'cx mut dyn Context: Freeze,

§

impl<'cx> Move for Writer<'cx>

§

impl<'cx> Unpin for Writer<'cx>
where *const u8 is !null: Unpin, &'cx mut dyn Context: Unpin,

§

impl<'cx> UnsafeUnpin for Writer<'cx>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.