pub struct DatumWriter {
pub indent: usize,
pub state: DatumWriterState,
}Expand description
General interface for formatting/printing Datum content. Note that if the passed writer returns an error at any point, the state of the writer is indeterminate, as it can be mid-token or part-way through a comment.
Fields§
§indent: usizeIndentation level (in tabs).
state: DatumWriterStateWriter’s state. Beware: Editing this improperly can create unreadable output.
Implementations§
Source§impl DatumWriter
impl DatumWriter
Sourcepub fn emit_whitespace(&mut self, f: &mut dyn Write, list_end: bool) -> Result
pub fn emit_whitespace(&mut self, f: &mut dyn Write, list_end: bool) -> Result
Emits queued whitespace. If list_end is set, won’t emit a single space. Will still emit indentation.
Sourcepub fn write_newline(&mut self, f: &mut dyn Write) -> Result
pub fn write_newline(&mut self, f: &mut dyn Write) -> Result
Writes a newline and prepares for it.
Sourcepub fn write_comment(&mut self, f: &mut dyn Write, text: &str) -> Result
pub fn write_comment(&mut self, f: &mut dyn Write, text: &str) -> Result
Writes a line comment. Newlines are converted into more line comments.
Sourcepub fn write_token<B: Deref<Target = str>>(
&mut self,
f: &mut dyn Write,
token: &DatumToken<B>,
) -> Result
pub fn write_token<B: Deref<Target = str>>( &mut self, f: &mut dyn Write, token: &DatumToken<B>, ) -> Result
Writes a token.
Trait Implementations§
Source§impl Clone for DatumWriter
impl Clone for DatumWriter
Source§fn clone(&self) -> DatumWriter
fn clone(&self) -> DatumWriter
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DatumWriter
impl Debug for DatumWriter
Source§impl Default for DatumWriter
impl Default for DatumWriter
Source§fn default() -> DatumWriter
fn default() -> DatumWriter
Returns the “default value” for a type. Read more
Source§impl PartialEq for DatumWriter
impl PartialEq for DatumWriter
impl Copy for DatumWriter
impl Eq for DatumWriter
impl StructuralPartialEq for DatumWriter
Auto Trait Implementations§
impl Freeze for DatumWriter
impl RefUnwindSafe for DatumWriter
impl Send for DatumWriter
impl Sync for DatumWriter
impl Unpin for DatumWriter
impl UnwindSafe for DatumWriter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more