Files
unshell/unshell-lib/src/lib.rs
T

70 lines
1.7 KiB
Rust
Raw Normal View History

#![no_main]
pub mod client;
pub mod config;
2025-11-09 12:34:52 -07:00
pub mod logger;
pub mod module;
pub mod network;
pub mod server;
mod components;
pub use components::get_components;
mod announcement;
2025-11-24 13:13:06 -07:00
use std::fmt::{self, Debug};
pub use announcement::Announcement;
///Generic error type for module-related operations.
#[derive(Debug)]
pub enum ModuleError {
LibLoadingError(libloading::Error),
2025-11-09 12:34:52 -07:00
// LogError(log::SetLoggerError),
LinkError(String),
2025-11-10 22:18:21 -07:00
CryptError(String),
Error(String),
}
2025-11-10 22:18:21 -07:00
impl std::error::Error for ModuleError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
None
}
fn description(&self) -> &str {
"description() is deprecated; use Display"
}
fn cause(&self) -> Option<&dyn std::error::Error> {
Some(self)
}
}
impl fmt::Display for ModuleError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(format!("{:?}", self).as_str())
}
}
/// Trait for defining modules that have a runtime.
pub trait ModuleRuntime: Send + Sync {
/// Returns true if the module is running.
/// After returning false, the module will be dropped.
fn is_running(&self) -> bool;
/// Consumes the module, implementation should kill whatever is running.
fn kill(self: Box<Self>);
}
2025-11-13 11:52:01 -07:00
// pub trait Component {
// fn name(&self) -> &'static str;
// // fn start_runtime(&self, manager: Arc<Mutex<Manager>>) -> Option<Box<dyn ModuleRuntime>>;
2025-11-13 11:52:01 -07:00
// fn get_interface(&self) -> Box<dyn Interface>;
// fn clone_box(&self) -> Box<dyn Component>;
// }
2025-11-13 11:52:01 -07:00
// impl Clone for Box<dyn Component> {
// fn clone(&self) -> Box<dyn Component> {
// self.clone_box()
// }
// }