Struct dipstick::core::ControlScopeFn
[−]
[src]
pub struct ControlScopeFn<M> { /* fields omitted */ }
Returns a callback function to send commands to the metric scope. Writes can be performed by passing Some((&Metric, Value)) Flushes can be performed by passing None Used to write values to the scope or flush the scope buffer (if applicable). Simple applications may use only one scope. Complex applications may define a new scope fo each operation or request. Scopes can be moved acrossed threads (Send) but are not required to be thread-safe (Sync). Some implementations may be 'Sync', otherwise queue()ing or threadlocal() can be used.
Methods
impl<M> ControlScopeFn<M>
[src]
pub fn new<F>(scope_fn: F) -> Self where
F: Fn(ScopeCmd<M>) + 'static,
[src]
F: Fn(ScopeCmd<M>) + 'static,
Create a new metric scope based on the provided scope function.
use dipstick::ControlScopeFn; let ref mut scope: ControlScopeFn<String> = ControlScopeFn::new(|_cmd| { /* match cmd {} */ });
pub fn write(&self, metric: &M, value: Value)
[src]
Write a value to this scope.
let ref mut scope = dipstick::to_log().open_scope(false); scope.write(&"counter".to_string(), 6);
pub fn flush(&self)
[src]
Flush this scope, if buffered.
let ref mut scope = dipstick::to_log().open_scope(true); scope.flush();
pub fn flush_on_drop(self, enable: bool) -> Self
[src]
If scope is buffered, controls whether to flush the scope one last time when it is dropped. The default is true.
let ref mut scope = dipstick::to_log().open_scope(true).flush_on_drop(false);
Trait Implementations
impl<M: Clone> Clone for ControlScopeFn<M>
[src]
fn clone(&self) -> ControlScopeFn<M>
[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