Writer

Struct Writer 

Source
pub struct Writer { /* private fields */ }
Expand description

Writer that builds TOON output string from JSON values.

Implementations§

Source§

impl Writer

Source

pub fn new(options: EncodeOptions) -> Self

Create a new writer with the given options.

Source

pub fn finish(self) -> String

Finish writing and return the complete TOON string.

Source

pub fn write_str(&mut self, s: &str) -> ToonResult<()>

Source

pub fn write_char(&mut self, ch: char) -> ToonResult<()>

Source

pub fn write_newline(&mut self) -> ToonResult<()>

Source

pub fn write_indent(&mut self, depth: usize) -> ToonResult<()>

Source

pub fn write_delimiter(&mut self) -> ToonResult<()>

Source

pub fn write_key(&mut self, key: &str) -> ToonResult<()>

Source

pub fn write_array_header( &mut self, key: Option<&str>, length: usize, fields: Option<&[String]>, depth: usize, ) -> ToonResult<()>

Write an array header with key, length, and optional field list.

Source

pub fn write_empty_array_with_key( &mut self, key: Option<&str>, ) -> ToonResult<()>

Write an empty array header.

Source

pub fn needs_quoting(&self, s: &str, context: QuotingContext) -> bool

Source

pub fn write_quoted_string(&mut self, s: &str) -> ToonResult<()>

Source

pub fn write_value( &mut self, s: &str, context: QuotingContext, ) -> ToonResult<()>

Source

pub fn push_active_delimiter(&mut self, delim: Delimiter)

Source

pub fn pop_active_delimiter(&mut self)

Auto Trait Implementations§

§

impl Freeze for Writer

§

impl RefUnwindSafe for Writer

§

impl Send for Writer

§

impl Sync for Writer

§

impl Unpin for Writer

§

impl UnwindSafe for Writer

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 = 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.