pub struct Metadata(/* private fields */);Expand description
Arbitrary key-value metadata for additional properties.
Keys and values are both strings. This is a simple wrapper around
a HashMap with serde support.
§Examples
use agent_skills::Metadata;
let mut metadata = Metadata::new();
metadata.insert("author", "example-org");
metadata.insert("version", "1.0");
assert_eq!(metadata.get("author"), Some("example-org"));
assert_eq!(metadata.len(), 2);Implementations§
Source§impl Metadata
impl Metadata
Sourcepub fn from_pairs<K, V, I>(iter: I) -> Self
pub fn from_pairs<K, V, I>(iter: I) -> Self
Creates metadata from an iterator of key-value pairs.
§Examples
use agent_skills::Metadata;
let metadata = Metadata::from_pairs([
("author", "test"),
("version", "1.0"),
]);
assert_eq!(metadata.len(), 2);Sourcepub fn insert(&mut self, key: impl Into<String>, value: impl Into<String>)
pub fn insert(&mut self, key: impl Into<String>, value: impl Into<String>)
Inserts a key-value pair.
If the key already exists, the value is replaced.
Sourcepub fn get(&self, key: &str) -> Option<&str>
pub fn get(&self, key: &str) -> Option<&str>
Gets a value by key.
Returns None if the key doesn’t exist.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&str, &str)>
pub fn iter(&self) -> impl Iterator<Item = (&str, &str)>
Returns an iterator over key-value pairs.
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Returns true if the metadata contains the specified key.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Metadata
impl<'de> Deserialize<'de> for Metadata
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
Source§impl<K, V> FromIterator<(K, V)> for Metadata
impl<K, V> FromIterator<(K, V)> for Metadata
Source§impl<'a> IntoIterator for &'a Metadata
impl<'a> IntoIterator for &'a Metadata
Source§impl IntoIterator for Metadata
impl IntoIterator for Metadata
impl Eq for Metadata
impl StructuralPartialEq for Metadata
Auto Trait Implementations§
impl Freeze for Metadata
impl RefUnwindSafe for Metadata
impl Send for Metadata
impl Sync for Metadata
impl Unpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.