Struct quil::Context
[−]
[src]
pub struct Context(_);
A logging context.
Contexts contain meta data for the association with logged messages.
Methods
impl Context
[src]
fn new() -> Self
[src]
Creates a new context for use with a logger.
fn set<S>(&mut self, key: S, value: S) where
S: Into<String>,
[src]
S: Into<String>,
Sets a value within the context by a given key.
Arguments
key
- A key for the value.value
- The value to add to the context.
Examples
Setting a value:
ctx.set("key", "value");
Clearing a value:
ctx.set("key", "");
fn get(&self, key: &str) -> Option<&String>
[src]
Gets a value by key.
If the key does not exist then None will be returned.
Arguments
key
- A key for the value.
Examples
ctx.set("key", "value"); assert_eq!(ctx.get("key").unwrap(), "value");
fn merge(&self, context: Self) -> Self
[src]
Create a new merged context from the context merge
is called upon and
a given context. The given context's values take precedence.
Arguments
context
- A context that will be merged.
Examples
let context_a = context!{ a: "1", b: "2" }; let context_b = context!{ b: "3", c: "4" }; let merged_context = context_a.merge(context_b); assert_eq!(merged_context.get("a").unwrap(), "1"); assert_eq!(merged_context.get("b").unwrap(), "3"); assert_eq!(merged_context.get("c").unwrap(), "4");
fn iter(&self) -> Iter<String, String>
[src]
Returns an iterator to iterate through the data contained within the context.
fn into_iter(self) -> IntoIter<String, String>
[src]
Consumes the context returning an iterator to iterate through the data once contained within the context.
Trait Implementations
impl Debug for Context
[src]
impl Clone for Context
[src]
fn clone(&self) -> Context
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more