pub struct Metadata(/* private fields */);Expand description
Key → value metadata, stored as JSON values internally.
Converts to/from WIT list<tuple<string, list<u8>>> (CBOR) at the boundary.
Implementations§
Source§impl Metadata
impl Metadata
pub fn new() -> Self
Sourcepub fn insert(&mut self, key: impl Into<String>, value: impl Into<Value>)
pub fn insert(&mut self, key: impl Into<String>, value: impl Into<Value>)
Insert a value. Overwrites any existing entry for the key.
Sourcepub fn get_as<T: DeserializeOwned>(&self, key: &str) -> Option<T>
pub fn get_as<T: DeserializeOwned>(&self, key: &str) -> Option<T>
Get a value by key, deserializing into a typed value.
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Check if a key exists.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Metadata
impl RefUnwindSafe for Metadata
impl Send for Metadata
impl Sync for Metadata
impl Unpin for Metadata
impl UnsafeUnpin for Metadata
impl UnwindSafe for Metadata
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