Struct Observable

Source
pub struct Observable<T, Error = ()>
where T: Send + Sync + 'static, Error: Send + Sync + 'static,
{ /* private fields */ }
Expand description

An Observable represents a sequence of values which may be observed.

Implementations§

Source§

impl<T, Error> Observable<T, Error>
where T: Send + Sync + 'static, Error: Send + Sync + 'static,

Source

pub fn new<F, G>(subscriber: F) -> Self
where F: Fn(SubscriptionObserver<T, Error>) -> G + Send + Sync + 'static, G: Fn() + Send + Sync + 'static,

Constructs an observable given a callback.

Source

pub fn subscribe( &self, observer: impl Into<BoxedObserver<T, Error>>, ) -> Arc<Subscription<T, Error>>

Subscribes to the sequence with an observer.

Source

pub fn map<U, F>( &self, map_fn: impl Fn(T) -> U + Send + Sync + 'static, ) -> Observable<U, Error>
where U: Send + Sync + 'static, F: SubscriberFunction<U, Error>,

Returns a new Observable that performs a map on data from the original.

Source

pub fn filter<F>( &self, filter_fn: impl Fn(T) -> bool + 'static + Send + Sync, ) -> Observable<T, Error>
where T: Clone, F: SubscriberFunction<T, Error>,

Returns a new Observable that filters data specified by the predicate.

Trait Implementations§

Source§

impl<T, Error> Clone for Observable<T, Error>
where T: Send + Sync + 'static, Error: Send + Sync + 'static,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T, Iterable> From<Iterable> for Observable<T, ()>
where Iterable: IntoIterator<Item = T> + Send + Sync, T: Clone + Send + Sync + 'static,

Source§

fn from(value: Iterable) -> Self

Constructs an Observable from a list of values.

Auto Trait Implementations§

§

impl<T, Error> Freeze for Observable<T, Error>

§

impl<T, Error = ()> !RefUnwindSafe for Observable<T, Error>

§

impl<T, Error> Send for Observable<T, Error>

§

impl<T, Error> Sync for Observable<T, Error>

§

impl<T, Error> Unpin for Observable<T, Error>

§

impl<T, Error = ()> !UnwindSafe for Observable<T, Error>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.