pub struct Value {
pub kind: Option<Kind>,
/* private fields */
}Fields§
§kind: Option<Kind>Implementations§
Source§impl Value
impl Value
Sourcepub fn as_number(&self) -> Option<f64>
pub fn as_number(&self) -> Option<f64>
Returns the f64 value if this is a number, otherwise None.
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Returns the string value if this is a string, otherwise None.
Sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
Returns the bool value if this is a bool, otherwise None.
Sourcepub fn as_struct(&self) -> Option<&Struct>
pub fn as_struct(&self) -> Option<&Struct>
Returns a reference to the Struct if this is a struct value.
Sourcepub fn as_list(&self) -> Option<&ListValue>
pub fn as_list(&self) -> Option<&ListValue>
Returns a reference to the ListValue if this is a list value.
Sourcepub fn as_struct_mut(&mut self) -> Option<&mut Struct>
pub fn as_struct_mut(&mut self) -> Option<&mut Struct>
Returns a mutable reference to the Struct if this is a struct value.
Sourcepub fn as_list_mut(&mut self) -> Option<&mut ListValue>
pub fn as_list_mut(&mut self) -> Option<&mut ListValue>
Returns a mutable reference to the ListValue if this is a list value.
Trait Implementations§
Source§impl<'arbitrary> Arbitrary<'arbitrary> for Value
impl<'arbitrary> Arbitrary<'arbitrary> for Value
Source§fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured this type
needs to construct itself. Read moreSource§impl DefaultInstance for Value
impl DefaultInstance for Value
Source§fn default_instance() -> &'static Self
fn default_instance() -> &'static Self
Source§impl<'de> Deserialize<'de> for Value
Available on crate feature json only.
impl<'de> Deserialize<'de> for Value
json only.Source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
Source§impl FromIterator<Value> for ListValue
impl FromIterator<Value> for ListValue
Source§impl Message for Value
impl Message for Value
Source§fn compute_size(&self) -> u32
fn compute_size(&self) -> u32
Returns the total encoded size in bytes.
The result is a u32; the protobuf specification requires all
messages to fit within 2 GiB (2,147,483,647 bytes), so a
compliant message will never overflow this type.
Source§fn write_to(&self, buf: &mut impl BufMut)
fn write_to(&self, buf: &mut impl BufMut)
Source§fn merge_field(
&mut self,
tag: Tag,
buf: &mut impl Buf,
depth: u32,
) -> Result<(), DecodeError>
fn merge_field( &mut self, tag: Tag, buf: &mut impl Buf, depth: u32, ) -> Result<(), DecodeError>
buf. Read moreSource§fn cached_size(&self) -> u32
fn cached_size(&self) -> u32
compute_size() call. Read moreSource§fn encode(&self, buf: &mut impl BufMut)
fn encode(&self, buf: &mut impl BufMut)
Source§fn encode_length_delimited(&self, buf: &mut impl BufMut)
fn encode_length_delimited(&self, buf: &mut impl BufMut)
Source§fn encode_to_bytes(&self) -> Bytes
fn encode_to_bytes(&self) -> Bytes
bytes::Bytes. Read moreSource§fn decode(buf: &mut impl Buf) -> Result<Self, DecodeError>where
Self: Sized,
fn decode(buf: &mut impl Buf) -> Result<Self, DecodeError>where
Self: Sized,
Source§fn decode_from_slice(data: &[u8]) -> Result<Self, DecodeError>where
Self: Sized,
fn decode_from_slice(data: &[u8]) -> Result<Self, DecodeError>where
Self: Sized,
Source§fn decode_length_delimited(buf: &mut impl Buf) -> Result<Self, DecodeError>where
Self: Sized,
fn decode_length_delimited(buf: &mut impl Buf) -> Result<Self, DecodeError>where
Self: Sized,
Source§fn merge_to_limit(
&mut self,
buf: &mut impl Buf,
depth: u32,
limit: usize,
) -> Result<(), DecodeError>
fn merge_to_limit( &mut self, buf: &mut impl Buf, depth: u32, limit: usize, ) -> Result<(), DecodeError>
Source§fn merge_group(
&mut self,
buf: &mut impl Buf,
depth: u32,
field_number: u32,
) -> Result<(), DecodeError>
fn merge_group( &mut self, buf: &mut impl Buf, depth: u32, field_number: u32, ) -> Result<(), DecodeError>
buf, reading fields until an
EndGroup tag with the given field_number is encountered. Read moreSource§fn merge(&mut self, buf: &mut impl Buf, depth: u32) -> Result<(), DecodeError>
fn merge(&mut self, buf: &mut impl Buf, depth: u32) -> Result<(), DecodeError>
Source§fn merge_from_slice(&mut self, data: &[u8]) -> Result<(), DecodeError>
fn merge_from_slice(&mut self, data: &[u8]) -> Result<(), DecodeError>
Source§fn merge_length_delimited(
&mut self,
buf: &mut impl Buf,
depth: u32,
) -> Result<(), DecodeError>
fn merge_length_delimited( &mut self, buf: &mut impl Buf, depth: u32, ) -> Result<(), DecodeError>
Source§impl Serialize for Value
Available on crate feature json only.
impl Serialize for Value
json only.Source§fn serialize<S: Serializer>(&self, s: S) -> Result<S::Ok, S::Error>
fn serialize<S: Serializer>(&self, s: S) -> Result<S::Ok, S::Error>
Serializes as the corresponding JSON value.
The null, bool, string, object, and array variants map directly to
their JSON counterparts. The number variant serializes as a JSON
number via serialize_f64.
§Errors
Serialization fails if the number variant holds a non-finite value
(NaN, Infinity, -Infinity), because JSON numbers cannot represent
those values. Use DoubleValue if you need to
serialize non-finite floating-point values (which uses the proto3 JSON
string encoding "NaN" / "Infinity" / "-Infinity").