pub struct ObjectWriter { /* private fields */ }Expand description
What:
Builder of one compact JSON object in insertion order,
as JSON.stringify writes it.
A struct groups named fields;
this one holds the text written so far.
Why:
Records must list their fields in the incumbent’s order so the bytes match for the
same values;
escaping comes from serde_json,
which escapes the same characters
JSON.stringify does.
In TS you’d write (pseudocode):
JSON.stringify({ a: 1, b: 'x' })Implementations§
Source§impl ObjectWriter
Methods that append one field each and finish the object.
impl ObjectWriter
Methods that append one field each and finish the object.
Sourcepub fn new() -> Self
pub fn new() -> Self
What: Start an empty object. Why: Every record starts the same way.
In TS you’d write (pseudocode):
const record = {};Sourcepub fn string(&mut self, key: &str, value: &str) -> &mut Self
pub fn string(&mut self, key: &str, value: &str) -> &mut Self
What: Append a text field. Why: Most record fields are text.
In TS you’d write (pseudocode):
record[key] = value;Sourcepub fn integer(&mut self, key: &str, value: i64) -> &mut Self
pub fn integer(&mut self, key: &str, value: i64) -> &mut Self
What: Append a whole-number field. Why: Schema versions, process IDs and attempt numbers.
In TS you’d write (pseudocode):
record[key] = value;Sourcepub fn boolean(&mut self, key: &str, value: bool) -> &mut Self
pub fn boolean(&mut self, key: &str, value: bool) -> &mut Self
What: Append a boolean field. Why: Flags such as whether a prepared commit is signed.
In TS you’d write (pseudocode):
record[key] = value;Trait Implementations§
Source§impl Debug for ObjectWriter
impl Debug for ObjectWriter
Auto Trait Implementations§
impl Freeze for ObjectWriter
impl RefUnwindSafe for ObjectWriter
impl Send for ObjectWriter
impl Sync for ObjectWriter
impl Unpin for ObjectWriter
impl UnsafeUnpin for ObjectWriter
impl UnwindSafe for ObjectWriter
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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