Registry

Struct Registry 

Source
pub struct Registry { /* private fields */ }
Expand description

The awareness roster of one application.

Implementations§

Source§

impl Registry

Source

pub fn new(config: Config) -> Arc<Registry>

Source

pub fn value(&self) -> Value

The roster as a Beck value: Map[Str, T], actor to contribution.

Source

pub fn watch(&self) -> Receiver<Value>

Wake on every change to it. A subscription watches this only when the program’s page reads awareness — a program that never asks must not re-render when somebody navigates.

Source

pub fn here(&self) -> usize

How many actors are in the roster.

Source

pub fn refused(&self) -> u64

How many joins the capacity refused, for the life of this process.

Source

pub fn oversized(&self) -> u64

How many contributions the per-actor bound refused, for the life of this process.

Source

pub fn join(self: &Arc<Self>, actor: &str, contribution: Value) -> Guard

Record a connection’s first contribution. The roster holds it until the guard is dropped.

A guard for crate::presence::Guard’s reason: a subscription ends by returning, by erroring or by its socket dying, and a roster that only removed an actor on the happy path would fill up with people who left hours ago.

Source

pub fn update(&self, actor: &str, contribution: Value) -> bool

Publish a new contribution for an actor already in the roster.

Silently does nothing for an actor that is not — the capacity refused them, and a client navigating should not be a way to get in through a different door.

Returns whether the roster changed, which is what saves a re-render: the common navigation republishes the same route.

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more