pub struct AgentMeta {
pub entries: Vec<MetaEntry>,
}Fields§
§entries: Vec<MetaEntry>Operator-entered key/value rows, in display order. Producers
should go through AgentMeta::new / AgentMeta::upsert /
AgentMeta::remove so the invariants below hold; consumers can
then rely on them: unique non-empty keys, each trimmed.
Implementations§
Source§impl AgentMeta
impl AgentMeta
Sourcepub fn new<I: IntoIterator<Item = MetaEntry>>(entries: I) -> Self
pub fn new<I: IntoIterator<Item = MetaEntry>>(entries: I) -> Self
Construct from any iterator of entries, normalising: trim key and value, drop rows whose key is empty, and de-dup by key keeping the last occurrence’s value while preserving each key’s first-seen position. So two operators who enter the same logical set (any trailing whitespace / duplicate key / re-ordered) converge on the same stored JSON for a given field order.
Sourcepub fn upsert(
&mut self,
key: impl Into<String>,
value: impl Into<String>,
) -> bool
pub fn upsert( &mut self, key: impl Into<String>, value: impl Into<String>, ) -> bool
Set a key to a value (insert or overwrite). Trims both. Returns
true if the stored set changed (new key, or a different value for
an existing key), false on a no-op. An empty (post-trim) key is
rejected as a no-op — use AgentMeta::remove to drop a key.
pub fn get(&self, key: &str) -> Option<&str>
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl<'de> Deserialize<'de> for AgentMeta
impl<'de> Deserialize<'de> for AgentMeta
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>,
impl Eq for AgentMeta
impl StructuralPartialEq for AgentMeta
Auto Trait Implementations§
impl Freeze for AgentMeta
impl RefUnwindSafe for AgentMeta
impl Send for AgentMeta
impl Sync for AgentMeta
impl Unpin for AgentMeta
impl UnsafeUnpin for AgentMeta
impl UnwindSafe for AgentMeta
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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
key and return true if they are equal.