pub trait DictionaryExt {
// Required methods
fn get_t<T: OxiExtract>(&self, key: &str) -> Result<T::Out>;
fn get_opt_t<T: OxiExtract>(&self, key: &str) -> Result<Option<T::Out>>;
fn get_dict(&self, keys: &[&str]) -> Result<Option<Dictionary>>;
fn get_required_dict(&self, keys: &[&str]) -> Result<Dictionary>;
}Expand description
Extension trait for Dictionary to provide typed getters.
Required Methods§
Sourcefn get_t<T: OxiExtract>(&self, key: &str) -> Result<T::Out>
fn get_t<T: OxiExtract>(&self, key: &str) -> Result<T::Out>
Gets a required typed value from the dictionary using the OxiExtract trait.
Fails if the key is absent.
§Errors
- The key is missing.
- The value exists but cannot be converted to the requested type (unexpected kind).
Sourcefn get_opt_t<T: OxiExtract>(&self, key: &str) -> Result<Option<T::Out>>
fn get_opt_t<T: OxiExtract>(&self, key: &str) -> Result<Option<T::Out>>
Gets an optional typed value from the dictionary using the OxiExtract trait.
Returns Ok(None) if the key is absent instead of treating it as an error.
§Errors
- The value exists but cannot be converted to the requested type (unexpected kind).
Sourcefn get_dict(&self, keys: &[&str]) -> Result<Option<Dictionary>>
fn get_dict(&self, keys: &[&str]) -> Result<Option<Dictionary>>
Gets an optional nested Dictionary by traversing a sequence of keys.
Returns Ok(None) if any key in the path is absent.
§Errors
- A value is found for an intermediate key but it is not a
Dictionary(unexpected kind).
Sourcefn get_required_dict(&self, keys: &[&str]) -> Result<Dictionary>
fn get_required_dict(&self, keys: &[&str]) -> Result<Dictionary>
Gets a required nested Dictionary by traversing a sequence of keys.
Fails if any key in the path is missing.
§Errors
- A key in the path is missing.
- A value is found for an intermediate key but it is not a
Dictionary(unexpected kind).
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.
Implementors§
impl DictionaryExt for Dictionary
Implementation of DictionaryExt for Dictionary providing typed getters.