Skip to main content

Hub

Struct Hub 

Source
pub struct Hub<T, S> { /* private fields */ }
Expand description

One writer and its sessions: each session is pinned to a document, and rows stored through one session are forwarded to the document’s other sessions.

Implementations§

Source§

impl<T: PatchStore, S: Sink> Hub<T, S>

Source

pub fn new(store: T) -> Self

Source

pub fn store(&mut self) -> &mut T

Source

pub fn open( &mut self, doc_id: &str, owner: &str, sink: S, ) -> Result<u64, T::Error>

owner groups sessions for close_owner, e.g. a webview label.

Source

pub fn send(&mut self, session: u64, bytes: &[u8]) -> Result<(), T::Error>

Relays one frame. Responses go to session, new rows to the document’s other sessions. Stored rows are forwarded even when the sender’s own sink is gone: a retransmission stores nothing, so it would forward nothing. That session is then closed, and the call fails with CLOSED.

Source

pub fn retire_prefix(&mut self, prefix: &str) -> Result<usize, T::Error>

Notify and close sessions only after their subtree has been durably retired.

Source

pub fn close(&mut self, session: u64) -> bool

Source

pub fn close_owner(&mut self, owner: &str) -> usize

Closes every session of an owner; returns how many were open.

Source

pub fn session_count(&self) -> usize

Source§

impl<T: DocumentStore, S: Sink> Hub<T, S>

Source

pub fn delete_documents( &mut self, prefix: &str, preserve_rows: bool, ) -> Result<usize, T::Error>

Atomically retire stored data, then stop affected subscribers.

Auto Trait Implementations§

§

impl<T, S> Forget for Hub<T, S>

§

impl<T, S> Freeze for Hub<T, S>
where T: Freeze, BTreeMap<u64, Session<S>>: Freeze,

§

impl<T, S> Move for Hub<T, S>

§

impl<T, S> RefUnwindSafe for Hub<T, S>
where T: RefUnwindSafe, BTreeMap<u64, Session<S>>: RefUnwindSafe,

§

impl<T, S> Send for Hub<T, S>
where T: Send, BTreeMap<u64, Session<S>>: Send,

§

impl<T, S> Sync for Hub<T, S>
where T: Sync, BTreeMap<u64, Session<S>>: Sync,

§

impl<T, S> Unpin for Hub<T, S>
where T: Unpin, BTreeMap<u64, Session<S>>: Unpin,

§

impl<T, S> UnsafeUnpin for Hub<T, S>
where T: UnsafeUnpin, BTreeMap<u64, Session<S>>: UnsafeUnpin,

§

impl<T, S> UnwindSafe for Hub<T, S>
where T: UnwindSafe, BTreeMap<u64, Session<S>>: UnwindSafe,

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.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.