pub struct Component<S, O> { /* private fields */ }
Expand description

Component is a base that helps managing reactive components.

It consists of two parts: state and object. Object is listening to its state changes and updates accordingly, so all mutations are meant to be applied to the state.

Implementations§

source§

impl<S, O> Component<S, O>

source

pub fn obj(&self) -> Rc<O>

Returns Rc to the object managed by this Component.

source

pub fn state(&self) -> Rc<S>

Returns reference to the state of this Component.

source§

impl<S: ComponentState<O> + 'static, O: 'static> Component<S, O>

source

pub fn new(obj: Rc<O>, state: Rc<S>) -> Self

Returns new Component with a provided object and state.

Spawns all watchers of this Component.

source§

impl Component<State, Repository>

source

pub fn get(&self, id: PeerId) -> Option<Rc<PeerConnection>>

Returns PeerConnection stored in the repository by its ID.

source

pub fn get_all(&self) -> Vec<Rc<PeerConnection>>

Returns all PeerConnections stored in the repository.

source

pub fn connection_lost(&self)

Notifies all peer::Components about a RPC connection loss.

source

pub fn connection_recovered(&self)

Notifies all peer::Components about a RPC connection restore.

source

pub fn apply(&self, new_state: Room)

Updates this State with the provided proto::state::Room.

Trait Implementations§

source§

impl ComponentState<<Component<State, PeerConnection> as ComponentTypes>::Obj> for <Component as ComponentTypes>::State

source§

fn spawn_watchers( &self, s: &mut WatchersSpawner<Self, <Component as ComponentTypes>::Obj> )

Spawns all watchers required for this ComponentState.
source§

impl ComponentState<<Component<State, Receiver> as ComponentTypes>::Obj> for <Component as ComponentTypes>::State

source§

fn spawn_watchers( &self, s: &mut WatchersSpawner<Self, <Component as ComponentTypes>::Obj> )

Spawns all watchers required for this ComponentState.
source§

impl ComponentState<<Component<State, Repository> as ComponentTypes>::Obj> for <Component as ComponentTypes>::State

source§

fn spawn_watchers( &self, s: &mut WatchersSpawner<Self, <Component as ComponentTypes>::Obj> )

Spawns all watchers required for this ComponentState.
source§

impl ComponentState<<Component<State, Sender> as ComponentTypes>::Obj> for <Component as ComponentTypes>::State

source§

fn spawn_watchers( &self, s: &mut WatchersSpawner<Self, <Component as ComponentTypes>::Obj> )

Spawns all watchers required for this ComponentState.
source§

impl<S, O> ComponentTypes for Component<S, O>

§

type Obj = O

Type of object managed by Component.
§

type State = S

Type of Component’s state.
source§

impl<S: Debug, O: Debug> Debug for Component<S, O>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<S, O> Deref for Component<S, O>

§

type Target = Rc<O>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<S, O> !RefUnwindSafe for Component<S, O>

§

impl<S, O> !Send for Component<S, O>

§

impl<S, O> !Sync for Component<S, O>

§

impl<S, O> Unpin for Component<S, O>

§

impl<S, O> !UnwindSafe for Component<S, O>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<E> WrapTraced<E> for E

source§

fn wrap_traced(self, f: Frame) -> Traced<E>

Wraps this error into a Traced wrapper, storing the given Frame of a Trace inside.
§

impl<T> Formattable for Twhere T: Deref, <T as Deref>::Target: Formattable,