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
impl Channel
Sourcepub fn status(&self) -> ChannelStatus
pub fn status(&self) -> ChannelStatus
Returns the latest channel status.
Sourcepub fn status_changes(&self) -> ChannelStatusChanges
pub fn status_changes(&self) -> ChannelStatusChanges
Creates a stream of subsequent channel status changes.
Sourcepub async fn join(&self) -> Result<Payload, ClientError>
pub async fn join(&self) -> Result<Payload, ClientError>
Joins using the default join timeout and a freshly loaded payload.
Sourcepub async fn join_with_timeout(
&self,
timeout: Duration,
) -> Result<Payload, ClientError>
pub async fn join_with_timeout( &self, timeout: Duration, ) -> Result<Payload, ClientError>
Joins with an explicit timeout and a freshly loaded payload.
Sourcepub async fn call(
&self,
event: impl Into<String>,
payload: impl Into<Payload>,
) -> Result<Reply, ClientError>
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.
Sourcepub async fn call_with_timeout(
&self,
event: impl Into<String>,
payload: impl Into<Payload>,
timeout: Duration,
) -> Result<Reply, ClientError>
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.
Sourcepub async fn call_json<Request, Response>(
&self,
event: impl Into<String>,
request: &Request,
) -> Result<Response, CallJsonError>
pub async fn call_json<Request, Response>( &self, event: impl Into<String>, request: &Request, ) -> Result<Response, CallJsonError>
Serializes a JSON request, requires an ok reply, and decodes its response.
Sourcepub async fn cast(
&self,
event: impl Into<String>,
payload: impl Into<Payload>,
) -> Result<(), ClientError>
pub async fn cast( &self, event: impl Into<String>, payload: impl Into<Payload>, ) -> Result<(), ClientError>
Sends an event without asking Phoenix for a reply.
Sourcepub async fn cast_with_timeout(
&self,
event: impl Into<String>,
payload: impl Into<Payload>,
timeout: Duration,
) -> Result<(), ClientError>
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.
Sourcepub async fn leave(&self) -> Result<Payload, ClientError>
pub async fn leave(&self) -> Result<Payload, ClientError>
Leaves using the default leave timeout.
Sourcepub async fn leave_with_timeout(
&self,
timeout: Duration,
) -> Result<Payload, ClientError>
pub async fn leave_with_timeout( &self, timeout: Duration, ) -> Result<Payload, ClientError>
Leaves and waits up to timeout for the server reply.
Sourcepub async fn next_event(&mut self) -> Option<ChannelEvent>
pub async fn next_event(&mut self) -> Option<ChannelEvent>
Returns the next event from this handle’s original event stream.
Sourcepub fn events(&self) -> Result<ChannelEvents, ClientError>
pub fn events(&self) -> Result<ChannelEvents, ClientError>
Creates an independent bounded channel event subscriber.
Sourcepub fn subscribe(
&self,
event: impl Into<String>,
) -> Result<EventSubscription, ClientError>
pub fn subscribe( &self, event: impl Into<String>, ) -> Result<EventSubscription, ClientError>
Subscribes to application messages with one event name.
Sourcepub fn presence(&self) -> Result<ChannelPresence<'_>, ClientError>
pub fn presence(&self) -> Result<ChannelPresence<'_>, ClientError>
Creates a synchronized Phoenix Presence consumer for this channel.