Skip to main content

Channel

Struct Channel 

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

Handle for one Phoenix channel topic.

Dropping the handle unregisters the topic and its pending operations.

Implementations§

Source§

impl Channel

Source

pub fn topic(&self) -> &str

Returns the registered channel topic.

Source

pub fn status(&self) -> ChannelStatus

Returns the latest channel status.

Source

pub fn status_changes(&self) -> ChannelStatusChanges

Creates a stream of subsequent channel status changes.

Source

pub async fn join(&self) -> Result<Payload, ClientError>

Joins using the default join timeout and a freshly loaded payload.

Source

pub async fn join_with_timeout( &self, timeout: Duration, ) -> Result<Payload, ClientError>

Joins with an explicit timeout and a freshly loaded payload.

Source

pub async fn call( &self, event: impl Into<String>, payload: impl Into<Payload>, ) -> Result<Reply, ClientError>

Sends an event and waits for its correlated reply.

Source

pub async fn call_with_timeout( &self, event: impl Into<String>, payload: impl Into<Payload>, timeout: Duration, ) -> Result<Reply, ClientError>

Sends an event and waits up to timeout for its correlated reply.

Source

pub async fn call_json<Request, Response>( &self, event: impl Into<String>, request: &Request, ) -> Result<Response, CallJsonError>
where Request: Serialize + ?Sized, Response: DeserializeOwned,

Serializes a JSON request, requires an ok reply, and decodes its response.

Source

pub async fn cast( &self, event: impl Into<String>, payload: impl Into<Payload>, ) -> Result<(), ClientError>

Sends an event without asking Phoenix for a reply.

Source

pub async fn cast_with_timeout( &self, event: impl Into<String>, payload: impl Into<Payload>, timeout: Duration, ) -> Result<(), ClientError>

Sends an event without asking Phoenix for a reply, waiting at most timeout for the frame to be accepted by the transport.

Source

pub async fn leave(&self) -> Result<Payload, ClientError>

Leaves using the default leave timeout.

Source

pub async fn leave_with_timeout( &self, timeout: Duration, ) -> Result<Payload, ClientError>

Leaves and waits up to timeout for the server reply.

Source

pub async fn next_event(&mut self) -> Option<ChannelEvent>

Returns the next event from this handle’s original event stream.

Source

pub fn events(&self) -> Result<ChannelEvents, ClientError>

Creates an independent bounded channel event subscriber.

Source

pub fn subscribe( &self, event: impl Into<String>, ) -> Result<EventSubscription, ClientError>

Subscribes to application messages with one event name.

Source

pub fn presence(&self) -> Result<ChannelPresence<'_>, ClientError>

Creates a synchronized Phoenix Presence consumer for this channel.

Trait Implementations§

Source§

impl Drop for Channel

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

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, 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