rx_rust/observer/
mod.rs

1pub mod boxed_observer;
2pub mod callback_observer;
3
4use educe::Educe;
5
6/// Represents the termination state of an operation, which can either be completed successfully or with an error.
7#[derive(Educe)]
8#[educe(Debug, Clone, PartialEq, Eq)]
9pub enum Termination<E> {
10    /// Indicates that the operation has completed successfully.
11    Completed,
12    /// Indicates that the operation has completed with an error.
13    Error(E),
14}
15
16/// A trait for observing the progress and termination state of an operation.
17pub trait Observer<T, E> {
18    /// Called when the next value in the operation is available.
19    fn on_next(&mut self, value: T);
20
21    /// Called when the operation has reached its termination state.
22    fn on_termination(self, termination: Termination<E>);
23}
24
25#[derive(Educe)]
26#[educe(Debug, Clone, PartialEq, Eq)]
27pub enum Event<T, E> {
28    Next(T),
29    Termination(Termination<E>),
30}