Struct pharos::ObserveConfig[][src]

pub struct ObserveConfig<Event> where
    Event: Clone + 'static + Send
{ /* fields omitted */ }
Expand description

Configuration for your event stream.

Pass to Observable::observe when subscribing. This let’s you choose the type of channel and let’s you set a filter to ignore certain events.

use pharos::*;

// We choose event type usize for simplicity. You choose whatever type you want here,
// see the bounds on the Event type parameter throughout this library.
//
let mut pharos = Pharos::<usize>::default();

// Use defaults, unbounded channel and no filter.
//
pharos.observe( ObserveConfig::default() );

// Use bounded channel and defaults for other options.
//
pharos.observe( Channel::Bounded(5).into() );

// Use a filter and defaults for other options.
// Will only receive events if they are bigger than three.
//
pharos.observe( Filter::Pointer( |evt| *evt > 3 ).into() );

// Set both channel and filter. Note you can only set one filter per observable.
//
let opts = ObserveConfig::default()

   .channel( Channel::Bounded( 5 ) )
   .filter ( |evt| *evt > 3        )
;

pharos.observe( opts );

Implementations

Choose which channel implementation to use for your event stream.

Filter your event stream with a predicate that is a fn pointer. You can only set one filter per observable.

Filter your event stream with a predicate that is a closure that captures environment. It is preferred to use filter if you can as this will box the closure. You can only set one filter per observable.

Trait Implementations

Formats the value using the given formatter. Read more

Create a default configuration:

  • no filter
  • an unbounded channel

Returns the “default value” for a type. Read more

Create a ObserveConfig from a Channel, getting default values for other options.

Performs the conversion.

Create a ObserveConfig from a Filter, getting default values for other options.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.