[WIP] Daemon & CLI

This commit is contained in:
Alex-Emmet 2026-07-23 23:13:02 +02:00
commit 8b158108bb
100 changed files with 6519 additions and 1596 deletions

View file

@ -0,0 +1,43 @@
use async_trait::async_trait;
use mtp::codec::CommunicationValue;
use std::time::Duration;
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum OmikronError {
Disconnected(String),
Timeout(String),
Authentication(String),
Internal(String),
}
impl std::fmt::Display for OmikronError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Disconnected(v)
| Self::Timeout(v)
| Self::Authentication(v)
| Self::Internal(v) => f.write_str(v),
}
}
}
impl std::error::Error for OmikronError {}
pub enum OmikronStartupError {
Construction(String),
InitialConnectionTimeout {
connection: std::sync::Arc<crate::omikron_connection::OmikronConnection>,
},
Authentication,
}
#[async_trait]
pub trait OmikronClient: Send + Sync {
async fn send_message(&self, value: &CommunicationValue) -> Result<(), OmikronError>;
async fn await_response(
&self,
value: &CommunicationValue,
timeout: Duration,
) -> Result<CommunicationValue, OmikronError>;
async fn reconnect(&self) -> Result<(), OmikronError>;
async fn is_connected(&self) -> bool;
}