pub struct KeyedEmitter<'a, B: JsonBackend> { /* private fields */ }Expand description
Single-use handle returned by JsonEmitter::key.
Consumed by KeyedEmitter::object, KeyedEmitter::array,
KeyedEmitter::value, KeyedEmitter::open_object, or
KeyedEmitter::open_array.
Implementations§
Source§impl<B: JsonBackend> KeyedEmitter<'_, B>
impl<B: JsonBackend> KeyedEmitter<'_, B>
Sourcepub fn array<F>(self, f: F) -> Result<()>
pub fn array<F>(self, f: F) -> Result<()>
Consume the key and write an array value via closure.
Best-effort scope guard: if the closure returns Err, the array close is
still attempted; the closure’s error takes precedence.
§Errors
Returns Err if a key is not allowed here, or if the closure or backend errors.
Sourcepub fn object<F>(self, f: F) -> Result<()>
pub fn object<F>(self, f: F) -> Result<()>
Consume the key and write an object value via closure.
Best-effort scope guard: if the closure returns Err, the object close is
still attempted; the closure’s error takes precedence.
§Errors
Returns Err if a key is not allowed here, or if the closure or backend errors.
Sourcepub fn open_array(self) -> Result<()>
pub fn open_array(self) -> Result<()>
Consume the key and open an array. Caller must later call
JsonEmitter::close_array on the underlying emitter.
§Errors
Returns Err if a key is not allowed here, or if the backend errors.
Sourcepub fn open_object(self) -> Result<()>
pub fn open_object(self) -> Result<()>
Consume the key and open an object. Caller must later call
JsonEmitter::close_object on the underlying emitter.
§Errors
Returns Err if a key is not allowed here, or if the backend errors.