pub enum ProjectedValue {
Text(String),
List(Vec<String>),
Map(BTreeMap<String, String>),
}Expand description
What an item’s metadata holds at one projected key and path, when it holds a value a projection can show.
Variants§
Text(String)
A string, the empty string included.
List(Vec<String>)
An array whose every element is a string, in array order.
Map(BTreeMap<String, String>)
An object whose every value is a string, in ascending byte order of its keys whatever order the JSON was written in.
Implementations§
Source§impl ProjectedValue
impl ProjectedValue
Sourcepub fn read(
metadata: &BTreeMap<String, Value>,
key: &str,
path: &[String],
) -> Result<Option<Self>, String>
pub fn read( metadata: &BTreeMap<String, Value>, key: &str, path: &[String], ) -> Result<Option<Self>, String>
The value metadata holds at key and then each object key of path in turn:
Ok(None) for nothing there or null, and otherwise the value, or — for any other
shape — Err with what was found, as a refusal spells it: a boolean, a number, or
for a mixed array or object an array whose element 2 is a number or
an object whose value at key "b" is an array.
§Errors
The shape found, when it is none a projection can show.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether the value shows nothing: the empty string, the empty array or the empty object.
Sourcepub fn entry_refusal<'a>(
field: &str,
key: &str,
earlier: impl IntoIterator<Item = &'a str>,
noun: &str,
) -> Option<String>
pub fn entry_refusal<'a>( field: &str, key: &str, earlier: impl IntoIterator<Item = &'a str>, noun: &str, ) -> Option<String>
Why one metadata_fields entry naming field and key cannot stand beside the
earlier fields of the same source, compared ignoring ASCII case — or None when it
can: a blank field, a blank key, a key under MetadataKey::RESERVED_NAMESPACE, or a
field an earlier entry names, which the refusal calls a noun (board field, say). A
source refusing field names of its own checks them after this.