pub enum Parameter {
Bool(bool),
Integer(i64),
String(String),
ListInt(Vec<i64>),
Float(f64),
ListFloat(Vec<f64>),
ListString(Vec<String>),
Timestamp(DateTime<Utc>),
}Expand description
A typed metadata parameter sent as part of output messages.
Parameters are stored by key in MetadataParameters. The get_*_param
helpers (get_string_param, get_integer_param, get_bool_param)
are type-checked: they return the value only when the stored variant matches
the requested type, and None both for a missing key and for a key whose
stored value has a different type. Callers therefore never need to match on
the variant themselves for the common scalar cases.
use dora_message::metadata::{
get_integer_param, get_string_param, MetadataParameters, Parameter,
};
let mut params = MetadataParameters::new();
params.insert("frame".to_string(), Parameter::Integer(7));
// Matching type -> the value.
assert_eq!(get_integer_param(¶ms, "frame"), Some(7));
// Wrong requested type -> None (not a panic, not a coercion).
assert_eq!(get_string_param(¶ms, "frame"), None);
// Missing key -> None.
assert_eq!(get_integer_param(¶ms, "absent"), None);Variants§
Bool(bool)
A boolean value.
Integer(i64)
A signed 64-bit integer value.
String(String)
A UTF-8 string value.
ListInt(Vec<i64>)
A list of signed 64-bit integers.
Float(f64)
A 64-bit floating-point value.
ListFloat(Vec<f64>)
A list of 64-bit floating-point values.
ListString(Vec<String>)
A list of UTF-8 strings.
Timestamp(DateTime<Utc>)
A UTC timestamp.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Parameter
impl<'de> Deserialize<'de> for Parameter
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Parameter
Auto Trait Implementations§
impl Freeze for Parameter
impl RefUnwindSafe for Parameter
impl Send for Parameter
impl Sync for Parameter
impl Unpin for Parameter
impl UnsafeUnpin for Parameter
impl UnwindSafe for Parameter
Blanket Implementations§
impl<T> Allocation for T
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