daemon: Allow context-specific commands on the message channel

This commit is contained in:
Vicki Pfau 2024-05-22 21:04:13 -07:00 committed by Jeremy Whiting
parent b582d51c90
commit 1a69cce50b
3 changed files with 50 additions and 13 deletions

View file

@ -41,6 +41,7 @@ struct UserContext {}
impl DaemonContext for UserContext {
type State = UserState;
type Config = UserConfig;
type Command = ();
#[cfg(not(test))]
fn user_config_path(&self) -> Result<PathBuf> {
@ -79,6 +80,15 @@ impl DaemonContext for UserContext {
// Nothing to do yet
Ok(())
}
async fn handle_command(
&mut self,
_cmd: Self::Command,
_daemon: &mut Daemon<UserContext>,
) -> Result<()> {
// Nothing to do yet
Ok(())
}
}
async fn create_connections() -> Result<(Connection, Connection)> {
@ -103,7 +113,7 @@ pub async fn daemon() -> Result<()> {
let stdout_log = fmt::layer();
let subscriber = Registry::default().with(stdout_log);
let (_tx, rx) = channel();
let (_tx, rx) = channel::<UserContext>();
let (_session, system) = match create_connections().await {
Ok(c) => c,