Struct wick_packet::RuntimeConfig
source · 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 copy 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 RuntimeConfigwhere
K: Into<String>,
impl<K, const N: usize> From<[(K, Value); N]> for RuntimeConfigwhere K: Into<String>,
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<HashMap<String, Value, RandomState>> for RuntimeConfig
impl From<HashMap<String, Value, RandomState>> for RuntimeConfig
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<RuntimeConfig> for RuntimeConfig
impl PartialEq<RuntimeConfig> for RuntimeConfig
source§fn eq(&self, other: &RuntimeConfig) -> bool
fn eq(&self, other: &RuntimeConfig) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.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 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