pub struct RuntimeConfig(/* private fields */);
Implementations§
Source§impl RuntimeConfig
impl RuntimeConfig
Sourcepub fn coerce_key<T>(&self, key: &str) -> Result<T, Error>where
T: DeserializeOwned,
pub fn coerce_key<T>(&self, key: &str) -> Result<T, Error>where
T: DeserializeOwned,
Get a value from the configuration map, deserializing it into the target type.
Sourcepub fn from_value(value: Value) -> Result<Self, Error>
pub fn from_value(value: Value) -> Result<Self, Error>
Convert a serde_json::Value into a RuntimeConfig.
Trait Implementations§
Source§impl Clone for RuntimeConfig
impl Clone for RuntimeConfig
Source§fn clone(&self) -> RuntimeConfig
fn clone(&self) -> RuntimeConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for RuntimeConfig
impl Debug for RuntimeConfig
Source§impl Default for RuntimeConfig
impl Default for RuntimeConfig
Source§fn default() -> RuntimeConfig
fn default() -> RuntimeConfig
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for RuntimeConfig
impl<'de> Deserialize<'de> for RuntimeConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<K, const N: usize> From<[(K, Value); N]> for RuntimeConfig
impl<K, const N: usize> From<[(K, Value); N]> for RuntimeConfig
Source§fn from(arr: [(K, Value); N]) -> Self
fn from(arr: [(K, Value); N]) -> Self
§Examples
use wick_packet::RuntimeConfig;
let config = RuntimeConfig::from([("key1", "value".into()), ("key2", 4.into())]);
let key1 = config.coerce_key::<String>("key1").unwrap();
assert_eq!(key1, "value");
let key2 = config.coerce_key::<u16>("key2").unwrap();
assert_eq!(key2, 4);
Source§impl From<RuntimeConfig> for HashMap<String, Value>
impl From<RuntimeConfig> for HashMap<String, Value>
Source§fn from(value: RuntimeConfig) -> Self
fn from(value: RuntimeConfig) -> Self
Converts to this type from the input type.
Source§impl IntoIterator for RuntimeConfig
impl IntoIterator for RuntimeConfig
Source§impl PartialEq for RuntimeConfig
impl PartialEq for RuntimeConfig
Source§impl Serialize for RuntimeConfig
impl Serialize for RuntimeConfig
Source§impl TryFrom<Value> for RuntimeConfig
impl TryFrom<Value> for RuntimeConfig
impl StructuralPartialEq for RuntimeConfig
Auto Trait Implementations§
impl Freeze for RuntimeConfig
impl RefUnwindSafe for RuntimeConfig
impl Send for RuntimeConfig
impl Sync for RuntimeConfig
impl Unpin for RuntimeConfig
impl UnwindSafe for RuntimeConfig
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