pub trait Stream<'sval> {
Show 52 methods
// Required methods
fn null(&mut self) -> Result;
fn bool(&mut self, value: bool) -> Result;
fn text_begin(&mut self, num_bytes: Option<usize>) -> Result;
fn text_fragment_computed(&mut self, fragment: &str) -> Result;
fn text_end(&mut self) -> Result;
fn i64(&mut self, value: i64) -> Result;
fn seq_begin(&mut self, num_entries: Option<usize>) -> Result;
fn seq_value_begin(&mut self) -> Result;
fn seq_value_end(&mut self) -> Result;
fn seq_end(&mut self) -> Result;
// Provided methods
fn value<V: Value + ?Sized>(&mut self, v: &'sval V) -> Result { ... }
fn value_computed<V: Value + ?Sized>(&mut self, v: &V) -> Result { ... }
fn text_fragment(&mut self, fragment: &'sval str) -> Result { ... }
fn binary_begin(&mut self, num_bytes: Option<usize>) -> Result { ... }
fn binary_fragment(&mut self, fragment: &'sval [u8]) -> Result { ... }
fn binary_fragment_computed(&mut self, fragment: &[u8]) -> Result { ... }
fn binary_end(&mut self) -> Result { ... }
fn u8(&mut self, value: u8) -> Result { ... }
fn u16(&mut self, value: u16) -> Result { ... }
fn u32(&mut self, value: u32) -> Result { ... }
fn u64(&mut self, value: u64) -> Result { ... }
fn u128(&mut self, value: u128) -> Result { ... }
fn i8(&mut self, value: i8) -> Result { ... }
fn i16(&mut self, value: i16) -> Result { ... }
fn i32(&mut self, value: i32) -> Result { ... }
fn i128(&mut self, value: i128) -> Result { ... }
fn f32(&mut self, value: f32) -> Result { ... }
fn f64(&mut self, value: f64) -> Result { ... }
fn map_begin(&mut self, num_entries: Option<usize>) -> Result { ... }
fn map_key_begin(&mut self) -> Result { ... }
fn map_key_end(&mut self) -> Result { ... }
fn map_value_begin(&mut self) -> Result { ... }
fn map_value_end(&mut self) -> Result { ... }
fn map_end(&mut self) -> Result { ... }
fn enum_begin(
&mut self,
tag: Option<&Tag>,
label: Option<&Label<'_>>,
index: Option<&Index>,
) -> Result { ... }
fn enum_end(
&mut self,
tag: Option<&Tag>,
label: Option<&Label<'_>>,
index: Option<&Index>,
) -> Result { ... }
fn tagged_begin(
&mut self,
tag: Option<&Tag>,
label: Option<&Label<'_>>,
index: Option<&Index>,
) -> Result { ... }
fn tagged_end(
&mut self,
tag: Option<&Tag>,
label: Option<&Label<'_>>,
index: Option<&Index>,
) -> Result { ... }
fn tag(
&mut self,
tag: Option<&Tag>,
label: Option<&Label<'_>>,
index: Option<&Index>,
) -> Result { ... }
fn tag_hint(&mut self, tag: &Tag) -> Result { ... }
fn record_begin(
&mut self,
tag: Option<&Tag>,
label: Option<&Label<'_>>,
index: Option<&Index>,
num_entries: Option<usize>,
) -> Result { ... }
fn record_value_begin(
&mut self,
tag: Option<&Tag>,
label: &Label<'_>,
) -> Result { ... }
fn record_value_end(
&mut self,
tag: Option<&Tag>,
label: &Label<'_>,
) -> Result { ... }
fn record_end(
&mut self,
tag: Option<&Tag>,
label: Option<&Label<'_>>,
index: Option<&Index>,
) -> Result { ... }
fn tuple_begin(
&mut self,
tag: Option<&Tag>,
label: Option<&Label<'_>>,
index: Option<&Index>,
num_entries: Option<usize>,
) -> Result { ... }
fn tuple_value_begin(&mut self, tag: Option<&Tag>, index: &Index) -> Result { ... }
fn tuple_value_end(&mut self, tag: Option<&Tag>, index: &Index) -> Result { ... }
fn tuple_end(
&mut self,
tag: Option<&Tag>,
label: Option<&Label<'_>>,
index: Option<&Index>,
) -> Result { ... }
fn record_tuple_begin(
&mut self,
tag: Option<&Tag>,
label: Option<&Label<'_>>,
index: Option<&Index>,
num_entries: Option<usize>,
) -> Result { ... }
fn record_tuple_value_begin(
&mut self,
tag: Option<&Tag>,
label: &Label<'_>,
index: &Index,
) -> Result { ... }
fn record_tuple_value_end(
&mut self,
tag: Option<&Tag>,
label: &Label<'_>,
index: &Index,
) -> Result { ... }
fn record_tuple_end(
&mut self,
tag: Option<&Tag>,
label: Option<&Label<'_>>,
index: Option<&Index>,
) -> Result { ... }
}Expand description
A consumer of structured data.
Each instance of a stream is expected to receive a single complete value.
Required Methods§
Sourcefn null(&mut self) -> Result
fn null(&mut self) -> Result
Stream null, the absence of any other meaningful value.
Null is a complete value.
Sourcefn text_begin(&mut self, num_bytes: Option<usize>) -> Result
fn text_begin(&mut self, num_bytes: Option<usize>) -> Result
Start a UTF8 text string.
After this call, a stream expects a series of zero or more calls to Stream::text_fragment and Stream::text_fragment_computed.
A call to Stream::text_end completes the value.
This method accepts a num_bytes hint, which hints the length of the text value in bytes.
If a value for num_bytes is provided, it must be accurate.
Sourcefn text_fragment_computed(&mut self, fragment: &str) -> Result
fn text_fragment_computed(&mut self, fragment: &str) -> Result
Stream a fragment of UTF8 text, borrowed for some arbitrarily short lifetime.
This method may only be called in the context of a text value, between a call to Stream::text_begin and Stream::text_end.
Sourcefn text_end(&mut self) -> Result
fn text_end(&mut self) -> Result
Complete a UTF8 text string.
This method may only be called in the context of a text value, after a call to Stream::text_begin.
Sourcefn i64(&mut self, value: i64) -> Result
fn i64(&mut self, value: i64) -> Result
Stream a signed 64bit integer.
An integer is a complete value.
Sourcefn seq_begin(&mut self, num_entries: Option<usize>) -> Result
fn seq_begin(&mut self, num_entries: Option<usize>) -> Result
Start a heterogeneous sequence of values.
After this call, a stream expects a series of zero or more sequence elements. Each element is a sequence of the following calls:
Stream::seq_value_begin.- A complete value.
Stream::seq_value_end.
A call to Stream::seq_end completes the value.
This method accepts a num_entries hint, which hints the number of elements in the sequence.
If a value for num_entries is provided, it must be accurate.
Sourcefn seq_value_begin(&mut self) -> Result
fn seq_value_begin(&mut self) -> Result
Start an individual value in a sequence.
This method may only be called in the context of a sequence value, after a call to Stream::seq_begin.
This call must be followed by a complete value, then a call to Stream::seq_value_end.
Sequence elements cannot be empty.
Sourcefn seq_value_end(&mut self) -> Result
fn seq_value_end(&mut self) -> Result
Complete an individual value in a sequence.
This method may only be called in the context of an element in a sequence value, after a call to Stream::seq_value_begin.
Sequence elements cannot be empty.
Sourcefn seq_end(&mut self) -> Result
fn seq_end(&mut self) -> Result
Complete a heterogeneous sequence of values.
This method may only be called in the context of a sequence value, after a call to Stream::seq_begin.
Provided Methods§
Sourcefn value_computed<V: Value + ?Sized>(&mut self, v: &V) -> Result
fn value_computed<V: Value + ?Sized>(&mut self, v: &V) -> Result
Recurse into a nested value, borrowed for some arbitrarily short lifetime.
Sourcefn text_fragment(&mut self, fragment: &'sval str) -> Result
fn text_fragment(&mut self, fragment: &'sval str) -> Result
Stream a fragment of UTF8 text.
This method may only be called in the context of a text value, between a call to Stream::text_begin and Stream::text_end.
Sourcefn binary_begin(&mut self, num_bytes: Option<usize>) -> Result
fn binary_begin(&mut self, num_bytes: Option<usize>) -> Result
Start a bitstring.
After this call, a stream expects a series of zero or more calls to Stream::binary_fragment and Stream::binary_fragment_computed.
A call to Stream::binary_end completes the value.
This method accepts a num_bytes hint, which hints the length of the bitstring value in bytes.
If a value for num_bytes is provided, it must be accurate.
Sourcefn binary_fragment(&mut self, fragment: &'sval [u8]) -> Result
fn binary_fragment(&mut self, fragment: &'sval [u8]) -> Result
Stream a fragment of a bitstring.
This method may only be called in the context of a bitstring value, between a call to Stream::binary_begin and Stream::binary_end.
Sourcefn binary_fragment_computed(&mut self, fragment: &[u8]) -> Result
fn binary_fragment_computed(&mut self, fragment: &[u8]) -> Result
Stream a fragment of a bitstring, borrowed for some arbitrarily short lifetime.
This method may only be called in the context of a bitstring value, between a call to Stream::binary_begin and Stream::binary_end.
Sourcefn binary_end(&mut self) -> Result
fn binary_end(&mut self) -> Result
Complete a bitstring.
This method may only be called in the context of a bitstring value, after a call to Stream::binary_begin.
Sourcefn u8(&mut self, value: u8) -> Result
fn u8(&mut self, value: u8) -> Result
Stream an unsigned 8bit integer.
An integer is a complete value.
Sourcefn u16(&mut self, value: u16) -> Result
fn u16(&mut self, value: u16) -> Result
Stream an unsigned 16bit integer.
An integer is a complete value.
Sourcefn u32(&mut self, value: u32) -> Result
fn u32(&mut self, value: u32) -> Result
Stream an unsigned 32bit integer.
An integer is a complete value.
Sourcefn u64(&mut self, value: u64) -> Result
fn u64(&mut self, value: u64) -> Result
Stream an unsigned 64bit integer.
An integer is a complete value.
Sourcefn u128(&mut self, value: u128) -> Result
fn u128(&mut self, value: u128) -> Result
Stream an unsigned 128bit integer.
An integer is a complete value.
Sourcefn i8(&mut self, value: i8) -> Result
fn i8(&mut self, value: i8) -> Result
Stream a signed 8bit integer.
An integer is a complete value.
Sourcefn i16(&mut self, value: i16) -> Result
fn i16(&mut self, value: i16) -> Result
Stream a signed 16bit integer.
An integer is a complete value.
Sourcefn i32(&mut self, value: i32) -> Result
fn i32(&mut self, value: i32) -> Result
Stream a signed 32bit integer.
An integer is a complete value.
Sourcefn i128(&mut self, value: i128) -> Result
fn i128(&mut self, value: i128) -> Result
Stream a signed 128bit integer.
An integer is a complete value.
Sourcefn f32(&mut self, value: f32) -> Result
fn f32(&mut self, value: f32) -> Result
Stream a 32bit binary floating point number.
An integer is a complete value.
Sourcefn f64(&mut self, value: f64) -> Result
fn f64(&mut self, value: f64) -> Result
Stream a 64bit binary floating point number.
An integer is a complete value.
Sourcefn map_begin(&mut self, num_entries: Option<usize>) -> Result
fn map_begin(&mut self, num_entries: Option<usize>) -> Result
Start a heterogeneous mapping of arbitrary keys to values.
After this call, a stream expects a series of zero or more map key-value pairs. Each key-value pair is a sequence of the following calls:
Stream::map_key_begin.- A complete value.
Stream::map_key_end.Stream::map_value_begin.- A complete value.
Stream::map_value_end.
A call to Stream::map_end completes the value.
This method accepts a num_entries hint, which hints the number of key-value pairs in the map.
If a value for num_entries is provided, it must be accurate.
Sourcefn map_key_begin(&mut self) -> Result
fn map_key_begin(&mut self) -> Result
Start a key in a key-value mapping.
This method may only be called in the context of a map value, after a call to Stream::map_begin.
This call must be followed by a complete value, then a call to Stream::map_key_end.
Map keys cannot be empty.
Each map key must be followed by a map value.
Sourcefn map_key_end(&mut self) -> Result
fn map_key_end(&mut self) -> Result
Complete a key in a key-value mapping.
This method may only be called in the context of a key in a map value, after a call to Stream::map_key_begin.
Map keys cannot be empty.
Each map key must be followed by a map value.
Sourcefn map_value_begin(&mut self) -> Result
fn map_value_begin(&mut self) -> Result
Start a value in a key-value mapping.
This method may only be called in the context of a map value, after a call to Stream::map_begin.
This call must be followed by a complete value.
Map values cannot be empty.
Sourcefn map_value_end(&mut self) -> Result
fn map_value_end(&mut self) -> Result
Complete a value in a key-value mapping.
This method may only be called in the context of a value in a map value, after a call to Stream::map_value_begin.
Map values cannot be empty.
Sourcefn map_end(&mut self) -> Result
fn map_end(&mut self) -> Result
Complete a heterogeneous mapping of arbitrary keys to values.
This method may only be called in the context of a map value, after a call to Stream::map_begin.
Sourcefn enum_begin(
&mut self,
tag: Option<&Tag>,
label: Option<&Label<'_>>,
index: Option<&Index>,
) -> Result
fn enum_begin( &mut self, tag: Option<&Tag>, label: Option<&Label<'_>>, index: Option<&Index>, ) -> Result
Start a variant in an enumerated type.
After this call, a stream expects a complete value as the enum variant.
An enum variant can be any type that accepts a Tag, Label, and Index parameter.
That includes:
- Tags (
Stream::tag). - Tagged values (
Stream::tagged_begin). - Records (
Stream::record_begin). - Tuples (
Stream::tuple_begin). - Enums (
Stream::enum_begin).
Enum variants may be empty.
A call to Stream::enum_end completes the value.
Sourcefn enum_end(
&mut self,
tag: Option<&Tag>,
label: Option<&Label<'_>>,
index: Option<&Index>,
) -> Result
fn enum_end( &mut self, tag: Option<&Tag>, label: Option<&Label<'_>>, index: Option<&Index>, ) -> Result
Complete a variant in an enumerated type.
This method may only be called in the context of an enum value, after a call to Stream::enum_begin.
Sourcefn tagged_begin(
&mut self,
tag: Option<&Tag>,
label: Option<&Label<'_>>,
index: Option<&Index>,
) -> Result
fn tagged_begin( &mut self, tag: Option<&Tag>, label: Option<&Label<'_>>, index: Option<&Index>, ) -> Result
Start a tagged value.
After this call, a stream expects a complete value.
A call to Stream::tagged_end completes the value.
Sourcefn tagged_end(
&mut self,
tag: Option<&Tag>,
label: Option<&Label<'_>>,
index: Option<&Index>,
) -> Result
fn tagged_end( &mut self, tag: Option<&Tag>, label: Option<&Label<'_>>, index: Option<&Index>, ) -> Result
Complete a tagged value.
This method may only be called in the context of a tagged value, after a call to Stream::tagged_begin.
Sourcefn tag(
&mut self,
tag: Option<&Tag>,
label: Option<&Label<'_>>,
index: Option<&Index>,
) -> Result
fn tag( &mut self, tag: Option<&Tag>, label: Option<&Label<'_>>, index: Option<&Index>, ) -> Result
Stream a standalone tag.
Standalone tags are complete values.
Sourcefn tag_hint(&mut self, tag: &Tag) -> Result
fn tag_hint(&mut self, tag: &Tag) -> Result
Use a tag as a hint without streaming it as a value.
Hints may be given at any point in a stream and may be interpreted by a stream in any way, but can’t be required for a correct result.
Sourcefn record_begin(
&mut self,
tag: Option<&Tag>,
label: Option<&Label<'_>>,
index: Option<&Index>,
num_entries: Option<usize>,
) -> Result
fn record_begin( &mut self, tag: Option<&Tag>, label: Option<&Label<'_>>, index: Option<&Index>, num_entries: Option<usize>, ) -> Result
Start a record.
After this call, a stream expects a series of zero or more record fields. Each field is a sequence of the following calls:
Stream::record_value_begin.- A complete value.
Stream::record_value_end.
A call to Stream::record_end completes the value.
This method accepts a num_entries hint, which hints the number of fields in the record.
If a value for num_entries is provided, it must be accurate.
Sourcefn record_value_begin(&mut self, tag: Option<&Tag>, label: &Label<'_>) -> Result
fn record_value_begin(&mut self, tag: Option<&Tag>, label: &Label<'_>) -> Result
Start a field in a record.
This method may only be called in the context of a record value, after a call to Stream::record_begin.
This call must be followed by a complete value, then a call to Stream::record_value_end.
Record fields cannot be empty.
Sourcefn record_value_end(&mut self, tag: Option<&Tag>, label: &Label<'_>) -> Result
fn record_value_end(&mut self, tag: Option<&Tag>, label: &Label<'_>) -> Result
Complete a field in a record.
This method may only be called in the context of a field in a record value, after a call to Stream::record_value_begin.
Record fields cannot be empty.
Sourcefn record_end(
&mut self,
tag: Option<&Tag>,
label: Option<&Label<'_>>,
index: Option<&Index>,
) -> Result
fn record_end( &mut self, tag: Option<&Tag>, label: Option<&Label<'_>>, index: Option<&Index>, ) -> Result
Complete a record.
This method may only be called in the context of a record value, after a call to Stream::record_begin.
Sourcefn tuple_begin(
&mut self,
tag: Option<&Tag>,
label: Option<&Label<'_>>,
index: Option<&Index>,
num_entries: Option<usize>,
) -> Result
fn tuple_begin( &mut self, tag: Option<&Tag>, label: Option<&Label<'_>>, index: Option<&Index>, num_entries: Option<usize>, ) -> Result
Start a tuple.
After this call, a stream expects a series of zero or more tuple fields. Each field is a sequence of the following calls:
Stream::tuple_value_begin.- A complete value.
Stream::tuple_value_end.
A call to Stream::tuple_end completes the value.
This method accepts a num_entries hint, which hints the number of fields in the tuple.
If a value for num_entries is provided, it must be accurate.
Sourcefn tuple_value_begin(&mut self, tag: Option<&Tag>, index: &Index) -> Result
fn tuple_value_begin(&mut self, tag: Option<&Tag>, index: &Index) -> Result
Start a field in a tuple.
This method may only be called in the context of a tuple value, after a call to Stream::tuple_begin.
This call must be followed by a complete value, then a call to Stream::tuple_value_end.
Tuple fields cannot be empty.
Sourcefn tuple_value_end(&mut self, tag: Option<&Tag>, index: &Index) -> Result
fn tuple_value_end(&mut self, tag: Option<&Tag>, index: &Index) -> Result
Complete a field in a tuple.
This method may only be called in the context of a field in a tuple value, after a call to Stream::tuple_value_begin.
Tuple fields cannot be empty.
Sourcefn tuple_end(
&mut self,
tag: Option<&Tag>,
label: Option<&Label<'_>>,
index: Option<&Index>,
) -> Result
fn tuple_end( &mut self, tag: Option<&Tag>, label: Option<&Label<'_>>, index: Option<&Index>, ) -> Result
Complete a tuple.
This method may only be called in the context of a tuple value, after a call to Stream::tuple_begin.
Sourcefn record_tuple_begin(
&mut self,
tag: Option<&Tag>,
label: Option<&Label<'_>>,
index: Option<&Index>,
num_entries: Option<usize>,
) -> Result
fn record_tuple_begin( &mut self, tag: Option<&Tag>, label: Option<&Label<'_>>, index: Option<&Index>, num_entries: Option<usize>, ) -> Result
Begin a type that may be treated as either a record or a tuple.
After this call, a stream expects a series of zero or more record tuple fields. Each field is a sequence of the following calls:
Stream::record_tuple_value_begin.- A complete value.
Stream::record_tuple_value_end.
A call to Stream::record_tuple_end completes the value.
This method accepts a num_entries hint, which hints the number of fields in the record tuple.
If a value for num_entries is provided, it must be accurate.
Sourcefn record_tuple_value_begin(
&mut self,
tag: Option<&Tag>,
label: &Label<'_>,
index: &Index,
) -> Result
fn record_tuple_value_begin( &mut self, tag: Option<&Tag>, label: &Label<'_>, index: &Index, ) -> Result
Begin a field in a type that may be treated as either a record or a tuple.
This method may only be called in the context of a record tuple value, after a call to Stream::record_tuple_begin.
This call must be followed by a complete value, then a call to Stream::record_tuple_value_end.
Record tuple fields cannot be empty.
Sourcefn record_tuple_value_end(
&mut self,
tag: Option<&Tag>,
label: &Label<'_>,
index: &Index,
) -> Result
fn record_tuple_value_end( &mut self, tag: Option<&Tag>, label: &Label<'_>, index: &Index, ) -> Result
Complete a field in a type that may be treated as either a record or a tuple.
This method may only be called in the context of a field in a record tuple value, after a call to Stream::record_tuple_value_begin.
Record tuple fields cannot be empty.
Sourcefn record_tuple_end(
&mut self,
tag: Option<&Tag>,
label: Option<&Label<'_>>,
index: Option<&Index>,
) -> Result
fn record_tuple_end( &mut self, tag: Option<&Tag>, label: Option<&Label<'_>>, index: Option<&Index>, ) -> Result
Complete a type that may be treated as either a record or a tuple.
This method may only be called in the context of a record tuple value, after a call to Stream::record_tuple_begin.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.