[−][src]Module herald::herald
Herald is a library to help you to track change of your data struct.
Herald require any change of your data struct should represent by a type,
and this type should implement LastChange
trait.
Herald macro attribute
Herald
provide a macro attribute to auto implement Herald
, and provide
a set of methods to update field. For example
use herald::prelude::*; #[herald] struct Point { x: f32, y: f32 } let mut p = Point { x: 0., y: 0., herald_impl: Default::default(), }; p.change_stream().subscribe(|v| { println!("{:?}", v.borrow().changes) }); p.set_x(1.); p.set_y(1.); // Will print like below // // PointChange { x: Some(Change { before: 0.0, after: 1.0 }), y: None } // PointChange { x: None, y: Some(Change { before: 0.0, after: 1.0 })
what features herald
attribute provide?
todo
what herald
attr do ?
herald
attr will implement a Herald
for your struct, and a set of set
method provide to update struct, any update across these method will be
tracked.
Assume we have below code
#[herald] struct Point { x: f32, y: f32 }
First, a herald_impl
(HeraldImpl) field with HeraldImpl<'_, Point>
into
point, it's a private field, but will be used to implement Herald
.
Second, Define a PointChange type to represent change of Point:
struct PointChange { x: Option<Change<f32>>, y: Option<Change<f32>>, }
Third, implement Herald
trait for Point by PointChange
and
herald_impl
. Fourth, set_x
and set_y
method provide on Point
, use
these method to update Point
will be tracked. Fifth, Define a PointState
type and impl set_state
method to update multi fields at once and change
will be tracked.
PointState { x: Option<f32>, y: Option<f32>, } impl Point { fn set_state(&mut self, state: PointState) { ... } }
Some field you not want to tracked.
If you want not track some field, you can use skip
argument, like
#[herald] struct Point { x: f32, #[herald(skip)] y: f32, }
Modules
observable | |
observer | |
ops | |
shared | |
subject | |
subscription |
Macros
of_sequence | Creates an observable producing a multiple values. |
Structs
Change | |
ChangeEvent | |
ConnectableObservable | |
EmptyEmitter | |
FnEmitter | |
HeraldImpl | A struct help for some type to implement |
LocalSubscription | |
NeverEmitter | |
ObservableBase | |
ObserverAll | |
ObserverComp | |
ObserverErr | |
ObserverN | |
RefChangeEvent | |
Shared | Shared wrap the Observable, subscribe and accept subscribe in a safe mode by SharedObservable. |
SharedSubscription | |
Subject | |
Subscriber | Implements the Observer trait and Subscription trait. While the Observer is the public API for consuming the values of an Observable, all Observers get converted to a Subscriber, in order to provide Subscription capabilities. |
SubscriptionGuard | An RAII implementation of a "scoped subscribed" of a subscription. When this structure is dropped (falls out of scope), the subscription will be unsubscribed. |
SubscriptionWrapper | Wrapper around a subscription which provides the
|
ThrowEmitter |
Enums
Schedulers |
Traits
Emitter | |
Herald | |
LastChange | A interface for deal with change which from Herald |
LocalEmitter | |
LocalObservable | |
Observable | |
Observer | An Observer is a consumer of values delivered by an Observable. One for each
type of notification delivered by the Observable: |
PayloadCopy | There are situations in which rxRust needs to copy items/errors, for example
when you use subjects or cloned observables. All items/errors which are
copyable (= implement |
Publisher | |
Scheduler | A Scheduler is an object to order task and schedule their execution. |
SharedEmitter | |
SharedObservable | |
SubscribeAll | |
SubscribeComplete | |
SubscribeErr | |
SubscribeNext | |
SubscriptionLike | Subscription returns from |
TearDownSize |
Functions
create | param |
delay_task | |
empty | Creates an observable that produces no values. |
from_future | Converts a |
from_future_result | Converts a |
from_iter | Creates an observable that produces values from an iterator. |
interval | Creates an observable which will fire at |
interval_at | Creates an observable which will fire at the time specified by |
never | Creates an observable that never emits anything. |
of | Creates an observable producing a single value. |
of_fn | Creates an observable that emits the return value of a callable. |
of_option | Creates an observable that potentially emits a single value from |
of_result | Creates an observable that emits value or the error from a |
repeat | Creates an observable producing same value repeated N times. |
throw | Creates an observable that emits no items, just terminates with an error. |
Type Definitions
LocalCloneBoxOp | |
LocalConnectableObservable | |
LocalSubject | |
SharedConnectableObservable | |
SharedSubject |
Attribute Macros
herald |