pub struct Writer { /* private fields */ }Expand description
Writer that builds TOON output string from JSON values.
Implementations§
Source§impl Writer
impl Writer
Sourcepub fn new(options: EncodeOptions) -> Self
pub fn new(options: EncodeOptions) -> Self
Create a new writer with the given options.
pub fn write_str(&mut self, s: &str) -> ToonResult<()>
pub fn write_char(&mut self, ch: char) -> ToonResult<()>
pub fn write_newline(&mut self) -> ToonResult<()>
pub fn write_indent(&mut self, depth: usize) -> ToonResult<()>
pub fn write_delimiter(&mut self) -> ToonResult<()>
pub fn write_key(&mut self, key: &str) -> ToonResult<()>
Sourcepub fn write_array_header(
&mut self,
key: Option<&str>,
length: usize,
fields: Option<&[String]>,
depth: usize,
) -> ToonResult<()>
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.
Sourcepub fn write_empty_array_with_key(
&mut self,
key: Option<&str>,
depth: usize,
) -> ToonResult<()>
pub fn write_empty_array_with_key( &mut self, key: Option<&str>, depth: usize, ) -> ToonResult<()>
Write an empty array header.
pub fn needs_quoting(&self, s: &str, context: QuotingContext) -> bool
pub fn write_quoted_string(&mut self, s: &str) -> ToonResult<()>
pub fn write_value( &mut self, s: &str, context: QuotingContext, ) -> ToonResult<()>
Sourcepub fn push_active_delimiter(&mut self, delim: Delimiter)
pub fn push_active_delimiter(&mut self, delim: Delimiter)
Push a new delimiter onto the stack (for nested arrays with different delimiters).
Sourcepub fn pop_active_delimiter(&mut self)
pub fn pop_active_delimiter(&mut self)
Pop the active delimiter, keeping at least one (the document default).
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§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more