Struct stakker_log::KvToJson
source · [−]pub struct KvToJson<'a> { /* private fields */ }
Expand description
JSON rendering of key-value pairs
When formatted with "{}"
, this produces a single-line compact
JSON rendering of the key-value pairs.
Implementations
sourceimpl<'a> KvToJson<'a>
impl<'a> KvToJson<'a>
sourcepub fn new(
kvscan: &'a dyn Fn(&mut dyn LogVisitor),
prefix: &'static str,
suffix: &'static str
) -> Self
pub fn new(
kvscan: &'a dyn Fn(&mut dyn LogVisitor),
prefix: &'static str,
suffix: &'static str
) -> Self
Create a KvToJson
ready to be formatted. The output will
have commas between items, but not at the start or end. A
list of key-value pairs would normally be surrounded by {
and }
in JSON, but since this type may be used in other
contexts, e.g. to extend a JSON object, only the plain
key-value pairs are output.
prefix
and suffix
are two strings which are output before
and after the key-value pairs, but only if the list of
key-value pairs is non-empty. So, for example, passing ","
and ""
would be suitable for extending a larger JSON object
that you’re already building up. Or alternatively, passing
",\"kv\":{"
and "}"
would allow an optional "kv"
item to
be added to a larger JSON object, but only if there is
key-value data.
Trait Implementations
Auto Trait Implementations
impl<'a> !RefUnwindSafe for KvToJson<'a>
impl<'a> !Send for KvToJson<'a>
impl<'a> !Sync for KvToJson<'a>
impl<'a> Unpin for KvToJson<'a>
impl<'a> !UnwindSafe for KvToJson<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more