ValueBuf

Struct ValueBuf 

Source
pub struct ValueBuf<'sval> { /* private fields */ }
Expand description

Buffer arbitrary values into a tree-like structure.

This type requires the alloc or std features, otherwise most methods will fail.

Implementations§

Source§

impl<'sval> ValueBuf<'sval>

Source

pub fn new() -> Self

Create a new empty value buffer.

Source

pub fn collect(v: &'sval (impl Value + ?Sized)) -> Result<Self, Error>

Buffer a value.

This method will fail if the alloc feature is not enabled.

Source

pub fn is_complete(&self) -> bool

Whether or not the contents of the value buffer are complete.

Source

pub fn clear(&mut self)

Clear this buffer so it can be re-used for future values.

Source

pub fn to_value(&self) -> Value<'sval>

Get an independent immutable value from this buffer.

Source

pub fn into_value(self) -> Value<'sval>

Convert this buffer into an immutable value.

Source

pub fn into_owned(self) -> Result<ValueBuf<'static>, Error>

Fully buffer any borrowed data, returning a buffer that doesn’t borrow anything.

This method will fail if the alloc feature is not enabled.

Source

pub fn into_err(self) -> Option<Error>

Take an error produced while attempting to buffer a value.

This method may return None even if streaming failed if a value failed without ever calling into the buffer.

Source§

impl ValueBuf<'static>

Source

pub fn collect_owned(v: impl Value) -> Result<Self, Error>

Fully buffer a value, including any internal borrowed data.

This method will fail if the alloc feature is not enabled.

Trait Implementations§

Source§

impl<'sval> Debug for ValueBuf<'sval>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'sval> Default for ValueBuf<'sval>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'sval> Stream<'sval> for ValueBuf<'sval>

Source§

fn null(&mut self) -> Result

Stream null, the absence of any other meaningful value. Read more
Source§

fn bool(&mut self, value: bool) -> Result

Stream a boolean. Read more
Source§

fn text_begin(&mut self, _: Option<usize>) -> Result

Start a UTF8 text string. Read more
Source§

fn text_fragment(&mut self, fragment: &'sval str) -> Result

Stream a fragment of UTF8 text. Read more
Source§

fn text_fragment_computed(&mut self, fragment: &str) -> Result

Stream a fragment of UTF8 text, borrowed for some arbitrarily short lifetime. Read more
Source§

fn text_end(&mut self) -> Result

Complete a UTF8 text string. Read more
Source§

fn binary_begin(&mut self, _: Option<usize>) -> Result

Start a bitstring. Read more
Source§

fn binary_fragment(&mut self, fragment: &'sval [u8]) -> Result

Stream a fragment of a bitstring. Read more
Source§

fn binary_fragment_computed(&mut self, fragment: &[u8]) -> Result

Stream a fragment of a bitstring, borrowed for some arbitrarily short lifetime. Read more
Source§

fn binary_end(&mut self) -> Result

Complete a bitstring. Read more
Source§

fn u8(&mut self, value: u8) -> Result

Stream an unsigned 8bit integer. Read more
Source§

fn u16(&mut self, value: u16) -> Result

Stream an unsigned 16bit integer. Read more
Source§

fn u32(&mut self, value: u32) -> Result

Stream an unsigned 32bit integer. Read more
Source§

fn u64(&mut self, value: u64) -> Result

Stream an unsigned 64bit integer. Read more
Source§

fn u128(&mut self, value: u128) -> Result

Stream an unsigned 128bit integer. Read more
Source§

fn i8(&mut self, value: i8) -> Result

Stream a signed 8bit integer. Read more
Source§

fn i16(&mut self, value: i16) -> Result

Stream a signed 16bit integer. Read more
Source§

fn i32(&mut self, value: i32) -> Result

Stream a signed 32bit integer. Read more
Source§

fn i64(&mut self, value: i64) -> Result

Stream a signed 64bit integer. Read more
Source§

fn i128(&mut self, value: i128) -> Result

Stream a signed 128bit integer. Read more
Source§

fn f32(&mut self, value: f32) -> Result

Stream a 32bit binary floating point number. Read more
Source§

fn f64(&mut self, value: f64) -> Result

Stream a 64bit binary floating point number. Read more
Source§

fn map_begin(&mut self, num_entries_hint: Option<usize>) -> Result

Start a heterogeneous mapping of arbitrary keys to values. Read more
Source§

fn map_key_begin(&mut self) -> Result

Start a key in a key-value mapping. Read more
Source§

fn map_key_end(&mut self) -> Result

Complete a key in a key-value mapping. Read more
Source§

fn map_value_begin(&mut self) -> Result

Start a value in a key-value mapping. Read more
Source§

fn map_value_end(&mut self) -> Result

Complete a value in a key-value mapping. Read more
Source§

fn map_end(&mut self) -> Result

Complete a heterogeneous mapping of arbitrary keys to values. Read more
Source§

fn seq_begin(&mut self, num_entries_hint: Option<usize>) -> Result

Start a heterogeneous sequence of values. Read more
Source§

fn seq_value_begin(&mut self) -> Result

Start an individual value in a sequence. Read more
Source§

fn seq_value_end(&mut self) -> Result

Complete an individual value in a sequence. Read more
Source§

fn seq_end(&mut self) -> Result

Complete a heterogeneous sequence of values. Read more
Source§

fn enum_begin( &mut self, tag: Option<&Tag>, label: Option<&Label<'_>>, index: Option<&Index>, ) -> Result

Start a variant in an enumerated type. Read more
Source§

fn enum_end( &mut self, _: Option<&Tag>, _: Option<&Label<'_>>, _: Option<&Index>, ) -> Result

Complete a variant in an enumerated type. Read more
Source§

fn tagged_begin( &mut self, tag: Option<&Tag>, label: Option<&Label<'_>>, index: Option<&Index>, ) -> Result

Start a tagged value. Read more
Source§

fn tagged_end( &mut self, _: Option<&Tag>, _: Option<&Label<'_>>, _: Option<&Index>, ) -> Result

Complete a tagged value. Read more
Source§

fn tag( &mut self, tag: Option<&Tag>, label: Option<&Label<'_>>, index: Option<&Index>, ) -> Result

Stream a standalone tag. Read more
Source§

fn tag_hint(&mut self, tag: &Tag) -> Result

Use a tag as a hint without streaming it as a value. Read more
Source§

fn record_begin( &mut self, tag: Option<&Tag>, label: Option<&Label<'_>>, index: Option<&Index>, num_entries: Option<usize>, ) -> Result

Start a record. Read more
Source§

fn record_value_begin(&mut self, tag: Option<&Tag>, label: &Label<'_>) -> Result

Start a field in a record. Read more
Source§

fn record_value_end(&mut self, _: Option<&Tag>, _: &Label<'_>) -> Result

Complete a field in a record. Read more
Source§

fn record_end( &mut self, _: Option<&Tag>, _: Option<&Label<'_>>, _: Option<&Index>, ) -> Result

Complete a record. Read more
Source§

fn tuple_begin( &mut self, tag: Option<&Tag>, label: Option<&Label<'_>>, index: Option<&Index>, num_entries: Option<usize>, ) -> Result

Start a tuple. Read more
Source§

fn tuple_value_begin(&mut self, tag: Option<&Tag>, index: &Index) -> Result

Start a field in a tuple. Read more
Source§

fn tuple_value_end(&mut self, _: Option<&Tag>, _: &Index) -> Result

Complete a field in a tuple. Read more
Source§

fn tuple_end( &mut self, _: Option<&Tag>, _: Option<&Label<'_>>, _: Option<&Index>, ) -> Result

Complete a tuple. Read more
Source§

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. Read more
Source§

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. Read more
Source§

fn record_tuple_value_end( &mut self, _: Option<&Tag>, _: &Label<'_>, _: &Index, ) -> Result

Complete a field in a type that may be treated as either a record or a tuple. Read more
Source§

fn record_tuple_end( &mut self, _: Option<&Tag>, _: Option<&Label<'_>>, _: Option<&Index>, ) -> Result

Complete a type that may be treated as either a record or a tuple. Read more
Source§

fn value<V>(&mut self, v: &'sval V) -> Result<(), Error>
where V: Value + ?Sized,

Recurse into a nested value.
Source§

fn value_computed<V>(&mut self, v: &V) -> Result<(), Error>
where V: Value + ?Sized,

Recurse into a nested value, borrowed for some arbitrarily short lifetime.
Source§

impl<'a> Value for ValueBuf<'a>

Source§

fn stream<'sval, S: Stream<'sval> + ?Sized>( &'sval self, stream: &mut S, ) -> Result

Stream this value through a Stream.
Source§

fn tag(&self) -> Option<Tag>

Get the tag of this value, if there is one.
Source§

fn to_bool(&self) -> Option<bool>

Try convert this value into a boolean.
Source§

fn to_f32(&self) -> Option<f32>

Try convert this value into a 32bit binary floating point number.
Source§

fn to_f64(&self) -> Option<f64>

Try convert this value into a 64bit binary floating point number.
Source§

fn to_i8(&self) -> Option<i8>

Try convert this value into a signed 8bit integer.
Source§

fn to_i16(&self) -> Option<i16>

Try convert this value into a signed 16bit integer.
Source§

fn to_i32(&self) -> Option<i32>

Try convert this value into a signed 32bit integer.
Source§

fn to_i64(&self) -> Option<i64>

Try convert this value into a signed 64bit integer.
Source§

fn to_i128(&self) -> Option<i128>

Try convert this value into a signed 128bit integer.
Source§

fn to_u8(&self) -> Option<u8>

Try convert this value into an unsigned 8bit integer.
Source§

fn to_u16(&self) -> Option<u16>

Try convert this value into an unsigned 16bit integer.
Source§

fn to_u32(&self) -> Option<u32>

Try convert this value into an unsigned 32bit integer.
Source§

fn to_u64(&self) -> Option<u64>

Try convert this value into an unsigned 64bit integer.
Source§

fn to_u128(&self) -> Option<u128>

Try convert this value into an unsigned 128bit integer.
Source§

fn to_text(&self) -> Option<&str>

Try convert this value into a text string.
Source§

fn to_binary(&self) -> Option<&[u8]>

Try convert this value into a bitstring.
Source§

impl<'sval> ValueRef<'sval> for ValueBuf<'sval>

Source§

fn stream_ref<S: Stream<'sval> + ?Sized>(&self, stream: &mut S) -> Result

Stream this value through a Stream.

Auto Trait Implementations§

§

impl<'sval> Freeze for ValueBuf<'sval>

§

impl<'sval> RefUnwindSafe for ValueBuf<'sval>

§

impl<'sval> Send for ValueBuf<'sval>

§

impl<'sval> Sync for ValueBuf<'sval>

§

impl<'sval> Unpin for ValueBuf<'sval>

§

impl<'sval> UnwindSafe for ValueBuf<'sval>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.