pub struct Handle { /* private fields */ }Expand description
Sends commands to a running Stream; cheap to clone.
Implementations§
Source§impl Handle
impl Handle
Sourcepub fn new(cmd_tx: Sender<Command>) -> Self
pub fn new(cmd_tx: Sender<Command>) -> Self
Wrap the command sender of a driver; normally obtained from Stream::new.
Sourcepub async fn connect(&self) -> Result<(), Error>
pub async fn connect(&self) -> Result<(), Error>
Open the connection (no-op if already connected).
Sourcepub fn try_connect(&self) -> Result<(), Error>
pub fn try_connect(&self) -> Result<(), Error>
Like Handle::connect, but fails with Error::QueueFull instead of waiting.
Sourcepub async fn disconnect(&self) -> Result<(), Error>
pub async fn disconnect(&self) -> Result<(), Error>
Close the connection; the driver stays alive and can connect again.
Sourcepub fn try_disconnect(&self) -> Result<(), Error>
pub fn try_disconnect(&self) -> Result<(), Error>
Like Handle::disconnect, but fails with Error::QueueFull instead of waiting.
Sourcepub async fn send_command(&self, msg: OutgoingMessage) -> Result<(), Error>
pub async fn send_command(&self, msg: OutgoingMessage) -> Result<(), Error>
Send a raw message on the current connection (not restored after a reconnect).
Sourcepub fn try_send_command(&self, msg: OutgoingMessage) -> Result<(), Error>
pub fn try_send_command(&self, msg: OutgoingMessage) -> Result<(), Error>
Like Handle::send_command, but fails with Error::QueueFull instead of waiting.
Sourcepub async fn subscribe(&self, topics: Vec<Topic>) -> Result<(), Error>
pub async fn subscribe(&self, topics: Vec<Topic>) -> Result<(), Error>
Subscribe to topics now and again after every reconnect.
Sourcepub fn try_subscribe(&self, topics: Vec<Topic>) -> Result<(), Error>
pub fn try_subscribe(&self, topics: Vec<Topic>) -> Result<(), Error>
Like Handle::subscribe, but fails with Error::QueueFull instead of waiting.
Sourcepub async fn unsubscribe(&self, topics: Vec<Topic>) -> Result<(), Error>
pub async fn unsubscribe(&self, topics: Vec<Topic>) -> Result<(), Error>
Unsubscribe from topics and stop restoring them.
Sourcepub fn try_unsubscribe(&self, topics: Vec<Topic>) -> Result<(), Error>
pub fn try_unsubscribe(&self, topics: Vec<Topic>) -> Result<(), Error>
Like Handle::unsubscribe, but fails with Error::QueueFull instead of waiting.