pub struct Channel { /* private fields */ }Implementations§
Source§impl Channel
impl Channel
Sourcepub const EVENT_BROADCAST_BUFFER: usize = 32
pub const EVENT_BROADCAST_BUFFER: usize = 32
How many events can be held onto before they start being dropped without being processed.
See Self::subscribe_event_broadcast() for more.
Sourcepub async fn new(backend: impl ChannelBackend) -> IoResult<Self>
pub async fn new(backend: impl ChannelBackend) -> IoResult<Self>
Create a new channel with the specified backend.
Sourcepub async fn send_raw_command(
&mut self,
command: RawCommand,
) -> Result<RawResponse, Error>
pub async fn send_raw_command( &mut self, command: RawCommand, ) -> Result<RawResponse, Error>
Send a RawCommand through this channel.
This yields the RawResponse if successful.
§Errors
Errors if the backend has an IO error.
Sourcepub async fn send_command<C>(
&mut self,
command: C,
) -> Result<C::Response, CommandError>where
C: Command,
pub async fn send_command<C>(
&mut self,
command: C,
) -> Result<C::Response, CommandError>where
C: Command,
Send a Command through this channel.
This yields the response type associated with the command.
§Errors
Errors if the backend has an IO error, or if the RawResponse represents an execution error or fails to parse into the typed response.
Sourcepub fn subscribe_event_broadcast(&self) -> BroadcastReceiver<Event>
pub fn subscribe_event_broadcast(&self) -> BroadcastReceiver<Event>
Subscribe to change events received by this channel.
This uses a tokio broadcast implementation, and has the same restrictions. This means every subscriber needs to handle an event before it is dropped, otherwise they will accumulate in the internal buffer. If the buffer’s maximum capacity is exceeded, the oldest event will be dropped, and any subscribers which have not handled it will never receive it.