Add ConnTx::send_only

This commit is contained in:
Joscha 2023-01-30 18:57:06 +01:00
parent 09a9620f8e
commit 46d9367670
5 changed files with 11 additions and 5 deletions

View file

@ -421,7 +421,7 @@ impl Instance {
if config.force_username || snapshot.nick.is_none() {
debug!("{}: Setting nick to username {}", config.name, username);
let name = username.to_string();
let _ = conn.tx().send(Nick { name });
conn.tx().send_only(Nick { name });
} else if let Some(nick) = &snapshot.nick {
debug!("{}: Not setting nick, already set to {}", config.name, nick);
}
@ -434,7 +434,7 @@ impl Instance {
r#type: AuthOption::Passcode,
passcode: Some(password.to_string()),
};
let _ = conn.tx().send(cmd);
conn.tx().send_only(cmd);
} else {
warn!("{}: Auth required but no password configured", config.name);
break;

View file

@ -330,6 +330,12 @@ impl ConnTx {
Self::finish_send::<C>(rx)
}
/// Like [`Self::send`] but ignoring the server's reply.
pub fn send_only<C: Into<Data>>(&self, cmd: C) {
let (tx, _) = oneshot::channel();
let _ = self.cmd_tx.send(ConnCommand::SendCmd(cmd.into(), tx));
}
pub async fn state(&self) -> Result<State> {
let (tx, rx) = oneshot::channel();
self.cmd_tx