pub enum Meta {
Identifier(String),
Value(MetaValue),
Array(Vec<Meta>),
Map(HashMap<String, Meta>),
Named(String, Box<Meta>),
}Expand description
A tree of annotations. See the module docs.
Variants§
Identifier(String)
A bare name, such as serialize.
Value(MetaValue)
A literal, such as 42 or 'foo'.
Array(Vec<Meta>)
An ordered list, written [a, b].
Map(HashMap<String, Meta>)
Named entries, written {a: 1, b: 2}.
Named(String, Box<Meta>)
A single named entry, written a = 1.
Implementations§
Source§impl Meta
impl Meta
Sourcepub fn parse(content: &str) -> Result<Meta, String>
pub fn parse(content: &str) -> Result<Meta, String>
Parses metadata from text, returning the parser error as a message.
Sourcepub fn as_identifier(&self) -> Option<&str>
pub fn as_identifier(&self) -> Option<&str>
Returns the identifier, or None for any other kind.
Sourcepub fn as_map(&self) -> Option<&HashMap<String, Meta>>
pub fn as_map(&self) -> Option<&HashMap<String, Meta>>
Returns the map, or None for any other kind.
Sourcepub fn as_named(&self) -> Option<(&str, &Meta)>
pub fn as_named(&self) -> Option<(&str, &Meta)>
Returns the name and its value, or None for any other kind.
Sourcepub fn has_id(&self, name: &str) -> bool
pub fn has_id(&self, name: &str) -> bool
Returns true when this tree mentions name, as an identifier, a string,
a map key or a named entry.
Searches one level into arrays. This is the usual predicate for a metadata query.
Sourcepub fn extract_by_id(&self, name: &str) -> Option<MetaExtract<'_>>
pub fn extract_by_id(&self, name: &str) -> Option<MetaExtract<'_>>
Returns what is stored under name, or None when it is absent.
Sourcepub fn items_iter(&self) -> MetaExtractIter<'_> ⓘ
pub fn items_iter(&self) -> MetaExtractIter<'_> ⓘ
Iterates the immediate children, treating a leaf as a single item.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Meta
impl<'de> Deserialize<'de> for Meta
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Meta, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Meta, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for Meta
impl Serialize for Meta
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for Meta
Auto Trait Implementations§
impl Freeze for Meta
impl RefUnwindSafe for Meta
impl Send for Meta
impl Sync for Meta
impl Unpin for Meta
impl UnsafeUnpin for Meta
impl UnwindSafe for Meta
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