[][src]Struct exonum::helpers::fabric::Context

pub struct Context { /* fields omitted */ }

Context is a type, used to keep some values from Command into CommandExtension and vice verse. To access values stored inside Context, use ContextKey.

Examples

use exonum::node::NodeConfig;
use exonum::helpers::fabric::{keys, Context};

fn get_node_config(context: &Context) -> NodeConfig {
    context.get(keys::NODE_CONFIG).unwrap()
}

Methods

impl Context
[src]

pub fn arg<T: FromStr>(&self, key: &str) -> Result<T, Error> where
    Error: From<<T as FromStr>::Err>, 
[src]

Gets value of the command line argument.

pub fn set_arg(&mut self, key: &str, value: String)
[src]

Inserts value to the command line arguments map.

pub fn arg_multiple<T: FromStr>(&self, key: &str) -> Result<Vec<T>, Error> where
    Error: From<<T as FromStr>::Err>, 
[src]

Gets multiple values of the command line argument.

pub fn set_arg_multiple(&mut self, key: &str, values: Vec<String>)
[src]

Inserts multiple values to the command line arguments map.

pub fn get<'de, T: Deserialize<'de>>(
    &self,
    key: ContextKey<T>
) -> Result<T, Error>
[src]

Gets the variable from the context.

pub fn set<T: Serialize>(
    &mut self,
    key: ContextKey<T>,
    value: T
) -> Option<Value>
[src]

Sets the variable in the context and returns the previous value.

Panic

Panics if value could not be serialized as TOML.

Trait Implementations

impl Default for Context
[src]

impl PartialEq<Context> for Context
[src]

impl Clone for Context
[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Context
[src]

Auto Trait Implementations

impl Send for Context

impl Sync for Context

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Erased for T

impl<T> Erased for T

impl<T> Clear for T where
    T: InitializableFromZeroed + ?Sized

impl<T> InitializableFromZeroed for T where
    T: Default

impl<T> Same for T

type Output = T

Should always be Self