pub trait MetaContainer: Clone + Debug {
Show 13 methods
// Required methods
fn insert_tag<T: MetaTag + Clone>(&mut self, tag: &T) -> Option<T>;
fn contains_tag<T: MetaTag + Clone>(&self) -> bool;
fn contains_type_id(&self, type_id: &TypeId) -> bool;
fn get_tag<T: MetaTag + Clone>(&self) -> Option<&T>;
fn get_tag_mut<T: MetaTag + Clone>(&mut self) -> Option<&mut T>;
fn remove_tag<T: MetaTag + Clone>(&mut self) -> Option<T>;
fn has_typed_metadata(&self) -> bool;
fn insert_string_tag(&mut self, key: &str, value: &str) -> Option<String>;
fn contains_string_tag(&self, key: &str) -> bool;
fn get_string_tag(&self, key: &str) -> Option<&str>;
fn get_string_tag_mut(&mut self, key: &str) -> Option<&mut String>;
fn remove_string_tag(&mut self, key: &str) -> Option<String>;
fn has_string_metadata(&self) -> bool;
}
Expand description
Core trait that is implemented by all containers of rustronomy metadata types.
MetaDataContainer
s consist of two different types of metadata:
- strongly typed metadata: these are rust data structures that implement
the
MetaTag
trait. These metadata may be accessed using the*operation*_tag
methods. - stringly typed metadata: these are just string key-value pairs. These
metadata may be accessed using the
*operation*_string_tag
methods.
§For data storage format implementers
Strongly typed metadata are the key to how rustronomy can transfer metadata between incompatible data storage formats. Implementers of data storage formats should take special care in storing this kind of metadata.
Required Methods§
Sourcefn insert_tag<T: MetaTag + Clone>(&mut self, tag: &T) -> Option<T>
fn insert_tag<T: MetaTag + Clone>(&mut self, tag: &T) -> Option<T>
Inserts strongly typed tag with type T
into the container. If the
container already had this type of metadata, its previous value will be
returned.
Sourcefn contains_tag<T: MetaTag + Clone>(&self) -> bool
fn contains_tag<T: MetaTag + Clone>(&self) -> bool
Returns true
if container contains a tag of type T
, false
otherwise
Sourcefn contains_type_id(&self, type_id: &TypeId) -> bool
fn contains_type_id(&self, type_id: &TypeId) -> bool
Returns true
if container contains a tag with a type that matches the
provided TypeId
, false
otherwise
Sourcefn get_tag<T: MetaTag + Clone>(&self) -> Option<&T>
fn get_tag<T: MetaTag + Clone>(&self) -> Option<&T>
Returns a reference to the strongly typed tag of type T
, if it exists.
Sourcefn get_tag_mut<T: MetaTag + Clone>(&mut self) -> Option<&mut T>
fn get_tag_mut<T: MetaTag + Clone>(&mut self) -> Option<&mut T>
Returns a mutable reference to the strongly typed tag of type T
, if it exists.
Sourcefn remove_tag<T: MetaTag + Clone>(&mut self) -> Option<T>
fn remove_tag<T: MetaTag + Clone>(&mut self) -> Option<T>
Removes the strongly typed tag with type T
from the container if it
is present. Returns the value of the removed entry.
Sourcefn has_typed_metadata(&self) -> bool
fn has_typed_metadata(&self) -> bool
Returns true
if this container has typed metadata, false
otherwise
Sourcefn insert_string_tag(&mut self, key: &str, value: &str) -> Option<String>
fn insert_string_tag(&mut self, key: &str, value: &str) -> Option<String>
Insert string tag with key key
into the container. If the container already
contained an entry with this key, its previous value will be returned.
Sourcefn contains_string_tag(&self, key: &str) -> bool
fn contains_string_tag(&self, key: &str) -> bool
Returns true
if container contains key key
, false
otherwise
Sourcefn get_string_tag(&self, key: &str) -> Option<&str>
fn get_string_tag(&self, key: &str) -> Option<&str>
Returns a &str
reference to the string tag with key key
, if it exists.
Sourcefn get_string_tag_mut(&mut self, key: &str) -> Option<&mut String>
fn get_string_tag_mut(&mut self, key: &str) -> Option<&mut String>
Returns a &mut String
mutable reference to the string tag with key key
,
if it exists.
Sourcefn remove_string_tag(&mut self, key: &str) -> Option<String>
fn remove_string_tag(&mut self, key: &str) -> Option<String>
Removes tag with key key
from the container, if it is present. Returns
the value of the removed entry.
Sourcefn has_string_metadata(&self) -> bool
fn has_string_metadata(&self) -> bool
Returns true
if this container has string metadata, false
otherwise
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.