Struct pharos::ObserveConfig [−][src]
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.
Trait Implementations
Create a default configuration:
- no filter
- an unbounded channel
Create a ObserveConfig from a Channel, getting default values for other options.
Auto Trait Implementations
impl<Event> !RefUnwindSafe for ObserveConfig<Event>
impl<Event> Send for ObserveConfig<Event>
impl<Event> !Sync for ObserveConfig<Event>
impl<Event> Unpin for ObserveConfig<Event>
impl<Event> !UnwindSafe for ObserveConfig<Event>