Skip to main content

ChatStreamHandler

Struct ChatStreamHandler 

Source
pub struct ChatStreamHandler<B: ChatBackend> { /* private fields */ }
Available on crate feature websocket only.
Expand description

The ChatStreamEnable / ChatStreamDisable handler of one WebSocket connection; see the module docs.

  • ChatStreamEnable replaces the subscription through EphemeralSubscription::replace_with with the CompanionStreams given to with_companions. Its error becomes the RequestError (invalidArguments, with the message’s id as requestId) and leaves the subscription unchanged. A malformed message is notRequest.
  • ChatStreamDisable clears it, silently, whether or not one was active.
  • Closing the connection clears it and stops delivery.

The companion values "vtc" and "scene" only switch the companion handler’s alias on: register on_subscription_change observers for them (jmap-chat-vtc-server and jmap-chat-scene-server do).

Implementations§

Source§

impl<B: ChatBackend> ChatStreamHandler<B>

Source

pub fn new( backend: Arc<B>, caller: B::CallerCtx, accounts: impl IntoIterator<Item = Id>, hub: &ChatEventHub, ) -> Self

The handler of a connection authenticated as caller, receiving the events of accounts (the accounts whose Chats and ChatContacts the owner sees, usually the owner’s own) from hub.

No companion value is recognized and the default ChatStreamLimits apply.

Source

pub fn with_companions(self, companions: CompanionStreams) -> Self

The companion WebSocket capabilities the server advertises, which decide whether "vtc" and "scene" in dataTypes are recognized.

Source

pub fn companions(&self) -> CompanionStreams

The companion capabilities in effect.

Source

pub fn with_limits(self, limits: ChatStreamLimits) -> Self

Replace the outbound rate limits.

Source

pub fn on_subscription_change( self, observer: impl FnMut(&EphemeralSubscription) + Send + 'static, ) -> Self

Call observer with the subscription each time it changes: after a successful ChatStreamEnable, after ChatStreamDisable, and with the empty subscription when the connection closes. Observers run in the order added, before the next client message is read.

Source

pub fn subscription(&self) -> EphemeralSubscription

The connection’s current subscription.

Trait Implementations§

Source§

impl<B: ChatBackend> Debug for ChatStreamHandler<B>

Source§

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

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

impl<B: ChatBackend> Drop for ChatStreamHandler<B>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<B: ChatBackend> ExtensionHandler for ChatStreamHandler<B>

Source§

fn message_types(&self) -> &[&str]

The client-to-server @types this handler takes. Read once, by Connection::with_extension.
Source§

fn start(&mut self, events: ExtensionSender)

Called once before the first message, with the queue for this connection’s server-to-client extension messages. The default drops it.
Source§

async fn handle(&mut self, message: ExtensionMessage) -> Result<(), JmapError>

Process one message. Success sends nothing (the drafts’ control messages are not acknowledged: “success is silent and failure produces a RequestError”). Err is sent as an RFC 8887 §4.3.4 RequestError with the message’s id as requestId, through RequestHandler::prepare_problem; its extra members become problem-details members (for example the Scene draft’s regionIds on a forbidden error).
Source§

async fn close(&mut self)

Called once when the connection ends. The default does nothing.

Auto Trait Implementations§

§

impl<B> !RefUnwindSafe for ChatStreamHandler<B>

§

impl<B> !Sync for ChatStreamHandler<B>

§

impl<B> !UnwindSafe for ChatStreamHandler<B>

§

impl<B> Forget for ChatStreamHandler<B>

§

impl<B> Freeze for ChatStreamHandler<B>
where Arc<Shared<B>>: Freeze,

§

impl<B> Move for ChatStreamHandler<B>

§

impl<B> Send for ChatStreamHandler<B>
where Arc<Shared<B>>: Send,

§

impl<B> Unpin for ChatStreamHandler<B>
where Arc<Shared<B>>: Unpin,

§

impl<B> UnsafeUnpin for ChatStreamHandler<B>
where Arc<Shared<B>>: UnsafeUnpin,

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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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 = !

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

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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