Struct TextWriter

Source
pub struct TextWriter<W>
where W: Write,
{ pub comma_style: CommaStyle, pub indentation: usize, pub escape_spaces: bool, /* private fields */ }
Expand description

The (optionally pretty-printing) text syntax Preserves writer.

Fields§

§comma_style: CommaStyle

Selects a comma style to use when printing.

§indentation: usize

Specifies indentation to use when pretty-printing; 0 disables pretty-printing.

§escape_spaces: bool

An aid to use of printed terms in shell scripts: set true to escape spaces embedded in strings and symbols.

Implementations§

Source§

impl TextWriter<&mut Vec<u8>>

Source

pub fn fmt_value<N, Enc>( f: &mut Formatter<'_>, enc: &mut Enc, v: &Value<N>, ) -> Result<(), Error>
where N: NestedValue, Enc: DomainEncode<<N as NestedValue>::Embedded>,

Writes v to f using text syntax. Selects indentation mode based on f.alternate().

Source

pub fn encode<N, Enc>(enc: &mut Enc, v: &N) -> Result<String, Error>
where N: NestedValue, Enc: DomainEncode<<N as NestedValue>::Embedded>,

Encode v to a String.

Source

pub fn encode_iovalue(v: &IOValue) -> Result<String, Error>

Encode v to a String.

Source§

impl<W> TextWriter<W>
where W: Write,

Source

pub fn new(w: W) -> TextWriter<W>

Construct a writer from the given byte sink w.

Source

pub fn set_comma_style(self, v: CommaStyle) -> TextWriter<W>

Update selected comma-printing style.

Source

pub fn set_escape_spaces(self, v: bool) -> TextWriter<W>

Update selected space-escaping style.

Source

pub fn borrow_write(&mut self) -> &mut W

Borrow the underlying byte sink.

Trait Implementations§

Source§

impl<W> Writer for TextWriter<W>
where W: Write,

Source§

fn flush(&mut self) -> Result<(), Error>

Flushes any buffered output.
Source§

fn write<N, Enc>(&mut self, enc: &mut Enc, v: &N) -> Result<(), Error>
where N: NestedValue, Enc: DomainEncode<<N as NestedValue>::Embedded>,

Writes NestedValue v to the output of this Writer.
Source§

fn write_value<N, Enc>( &mut self, enc: &mut Enc, v: &Value<N>, ) -> Result<(), Error>
where N: NestedValue, Enc: DomainEncode<<N as NestedValue>::Embedded>,

Writes Value v to the output of this Writer.

Auto Trait Implementations§

§

impl<W> Freeze for TextWriter<W>
where W: Freeze,

§

impl<W> RefUnwindSafe for TextWriter<W>
where W: RefUnwindSafe,

§

impl<W> Send for TextWriter<W>
where W: Send,

§

impl<W> Sync for TextWriter<W>
where W: Sync,

§

impl<W> Unpin for TextWriter<W>
where W: Unpin,

§

impl<W> UnwindSafe for TextWriter<W>
where W: UnwindSafe,

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<L, N> Codec<N> for L
where N: NestedValue,

Source§

fn parse<'a, T>(&'a self, value: &N) -> Result<T, ParseError>
where T: Parse<&'a L, N>,

Delegates to T::parse, using self as language and the given value as input.
Source§

fn unparse<'a, T>(&'a self, value: &T) -> N
where T: Unparse<&'a L, N>,

Delegates to value.unparse, using self as language.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more