use exo_shell_client::{Registration, ShellType, try_register};
pub enum ExoShellState {
Standalone,
Connected(Registration),
}
impl ExoShellState {
pub async fn try_connect(name: &str, capabilities: Vec<String>) -> Self {
match try_register(name, ShellType::BlissGui, capabilities).await {
Some(reg) => {
tracing::info!(
name,
session = %reg.session_id.0,
shell = %reg.shell_id.0,
"Connected to ExoShell"
);
Self::Connected(reg)
}
None => {
tracing::debug!("ExoShell not available, running standalone");
Self::Standalone
}
}
}
pub fn is_connected(&self) -> bool {
matches!(self, Self::Connected(_))
}
pub async fn disconnect(self) {
if let Self::Connected(reg) = self {
reg.unregister().await;
}
}
}