Enum Value
pub enum Value {
String(String),
Bool(bool),
I64(i64),
F64(f64),
}Available on crate feature
alloc only.Expand description
An owned value that can be sent across thread boundaries.
Unlike transient::Value, this type is fully owned and does not contain
any non-Send types like format_args!. This makes it suitable for
serialization and sending across threads via channels.
Cross-serialization compatible with transient::Value - the transient
variants will be converted to owned types during serialization.
§Examples
use veecle_telemetry::protocol::{owned, transient};
// Create a `transient::Value` with `format_args!`.
let count = 42;
let transient = transient::Value::Formatted(format_args!("count: {count}"));
// Serialize to JSON.
let json = serde_json::to_string(&transient)?;
assert_eq!(json, r#"{"String":"count: 42"}"#);
// Deserialize as `owned::Value`.
let owned: owned::Value = serde_json::from_str(&json)?;
let owned::Value::String(string) = owned else { panic!("unexpected variant") };
assert_eq!(string, "count: 42");Variants§
String(String)
A string value (owned)
Bool(bool)
A boolean value
I64(i64)
A 64-bit signed integer
F64(f64)
A 64-bit floating-point number
Trait Implementations§
§impl<'de> Deserialize<'de> for Value
impl<'de> Deserialize<'de> for Value
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Value, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Value, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
§impl Serialize for Value
impl Serialize for Value
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnwindSafe for Value
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more