pub struct MetadataStore { /* private fields */ }Expand description
The name-keyed metadata store: object name → { attribute → value }, string
values, deterministic iteration (a BTreeMap so the persisted JSON is
stable). Empty records are never retained (removing the last attribute drops
the whole record).
Implementations§
Source§impl MetadataStore
impl MetadataStore
pub fn new() -> Self
Sourcepub fn set_attribute(&mut self, name: &str, key: &str, value: &str)
pub fn set_attribute(&mut self, name: &str, key: &str, value: &str)
Set (or overwrite) one attribute of name’s record. An empty object name
or key is ignored (no phantom records).
Sourcepub fn remove_attribute(&mut self, name: &str, key: &str) -> bool
pub fn remove_attribute(&mut self, name: &str, key: &str) -> bool
Remove one attribute of name’s record, dropping the record if it becomes
empty. Returns whether the attribute existed.
Sourcepub fn attribute(&self, name: &str, key: &str) -> Option<&str>
pub fn attribute(&self, name: &str, key: &str) -> Option<&str>
One attribute’s value (None if the object or key is unknown).
Sourcepub fn record(&self, name: &str) -> BTreeMap<String, String>
pub fn record(&self, name: &str) -> BTreeMap<String, String>
One object’s whole record (empty map if the object has no metadata).
Sourcepub fn all(&self) -> &BTreeMap<String, BTreeMap<String, String>>
pub fn all(&self) -> &BTreeMap<String, BTreeMap<String, String>>
The whole store (all records), read-only.
Sourcepub fn density(&self, name: &str) -> f64
pub fn density(&self, name: &str) -> f64
The resolved density (mass per mm³) for name: its density attribute
parsed as a positive finite number, else DEFAULT_DENSITY.
Sourcepub fn record_json(&self, name: &str) -> String
pub fn record_json(&self, name: &str) -> String
One object’s record as a JSON object { key: value, ... } ({} when the
object has no metadata).
Sourcepub fn to_json(&self) -> Value
pub fn to_json(&self) -> Value
The whole store as a JSON value { name: { key: value, ... }, ... } — the
persisted shape and the whole-store getter.
Sourcepub fn to_json_string(&self) -> String
pub fn to_json_string(&self) -> String
The whole store as a JSON string (the whole-store getter’s string form).
Trait Implementations§
Source§impl Clone for MetadataStore
impl Clone for MetadataStore
Source§fn clone(&self) -> MetadataStore
fn clone(&self) -> MetadataStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MetadataStore
impl Debug for MetadataStore
Source§impl Default for MetadataStore
impl Default for MetadataStore
Source§fn default() -> MetadataStore
fn default() -> MetadataStore
Auto Trait Implementations§
impl Freeze for MetadataStore
impl RefUnwindSafe for MetadataStore
impl Send for MetadataStore
impl Sync for MetadataStore
impl Unpin for MetadataStore
impl UnsafeUnpin for MetadataStore
impl UnwindSafe for MetadataStore
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,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more