docs: Add comprehensive documentation and update planning
- Add docs/README.md with project overview and current status - Add docs/architecture.md with detailed architecture documentation - Add docs/development.md with development guide for contributors - Update .notes/todo.md to reflect architecture fix completion - Update .notes/plan.md with completed phases and next priorities Architecture fixes (daemon and dbus), bubblewrap integration are now complete. Ready for OCI integration phase.
This commit is contained in:
parent
1cc175c110
commit
97a9c40d7e
33 changed files with 4488 additions and 118 deletions
128
src/daemon_client.rs
Normal file
128
src/daemon_client.rs
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
use zbus::{Connection, Proxy};
|
||||
use std::error::Error;
|
||||
use serde_json;
|
||||
|
||||
/// Daemon client for communicating with apt-ostreed
|
||||
pub struct DaemonClient {
|
||||
connection: Connection,
|
||||
proxy: Proxy<'static>,
|
||||
}
|
||||
|
||||
impl DaemonClient {
|
||||
/// Create a new daemon client
|
||||
pub async fn new() -> Result<Self, Box<dyn Error>> {
|
||||
let connection = Connection::system().await?;
|
||||
let proxy = Proxy::new(
|
||||
&connection,
|
||||
"org.aptostree.dev",
|
||||
"/org/aptostree/dev/Daemon",
|
||||
"org.aptostree.dev.Daemon"
|
||||
).await?;
|
||||
|
||||
Ok(Self { connection, proxy })
|
||||
}
|
||||
|
||||
/// Ping the daemon
|
||||
pub async fn ping(&self) -> Result<String, Box<dyn Error>> {
|
||||
let reply: String = self.proxy.call("ping", &()).await?;
|
||||
Ok(reply)
|
||||
}
|
||||
|
||||
/// Get system status
|
||||
pub async fn status(&self) -> Result<String, Box<dyn Error>> {
|
||||
let reply: String = self.proxy.call("status", &()).await?;
|
||||
Ok(reply)
|
||||
}
|
||||
|
||||
/// Install packages
|
||||
pub async fn install_packages(&self, packages: Vec<String>, yes: bool, dry_run: bool) -> Result<String, Box<dyn Error>> {
|
||||
let reply: String = self.proxy.call("install_packages", &(packages, yes, dry_run)).await?;
|
||||
Ok(reply)
|
||||
}
|
||||
|
||||
/// Remove packages
|
||||
pub async fn remove_packages(&self, packages: Vec<String>, yes: bool, dry_run: bool) -> Result<String, Box<dyn Error>> {
|
||||
let reply: String = self.proxy.call("remove_packages", &(packages, yes, dry_run)).await?;
|
||||
Ok(reply)
|
||||
}
|
||||
|
||||
/// Upgrade system
|
||||
pub async fn upgrade_system(&self, yes: bool, dry_run: bool) -> Result<String, Box<dyn Error>> {
|
||||
let reply: String = self.proxy.call("upgrade_system", &(yes, dry_run)).await?;
|
||||
Ok(reply)
|
||||
}
|
||||
|
||||
/// Rollback system
|
||||
pub async fn rollback(&self, yes: bool, dry_run: bool) -> Result<String, Box<dyn Error>> {
|
||||
let reply: String = self.proxy.call("rollback", &(yes, dry_run)).await?;
|
||||
Ok(reply)
|
||||
}
|
||||
|
||||
/// List packages
|
||||
pub async fn list_packages(&self) -> Result<String, Box<dyn Error>> {
|
||||
let reply: String = self.proxy.call("list_packages", &()).await?;
|
||||
Ok(reply)
|
||||
}
|
||||
|
||||
/// Search packages
|
||||
pub async fn search_packages(&self, query: String, verbose: bool) -> Result<String, Box<dyn Error>> {
|
||||
let reply: String = self.proxy.call("search_packages", &(query, verbose)).await?;
|
||||
Ok(reply)
|
||||
}
|
||||
|
||||
/// Show package info
|
||||
pub async fn show_package_info(&self, package: String) -> Result<String, Box<dyn Error>> {
|
||||
let reply: String = self.proxy.call("show_package_info", &(package)).await?;
|
||||
Ok(reply)
|
||||
}
|
||||
|
||||
/// Show history
|
||||
pub async fn show_history(&self, verbose: bool, limit: u32) -> Result<String, Box<dyn Error>> {
|
||||
let reply: String = self.proxy.call("show_history", &(verbose, limit)).await?;
|
||||
Ok(reply)
|
||||
}
|
||||
|
||||
/// Checkout to different branch/commit
|
||||
pub async fn checkout(&self, target: String, yes: bool, dry_run: bool) -> Result<String, Box<dyn Error>> {
|
||||
let reply: String = self.proxy.call("checkout", &(target, yes, dry_run)).await?;
|
||||
Ok(reply)
|
||||
}
|
||||
|
||||
/// Prune deployments
|
||||
pub async fn prune_deployments(&self, keep: u32, yes: bool, dry_run: bool) -> Result<String, Box<dyn Error>> {
|
||||
let reply: String = self.proxy.call("prune_deployments", &(keep, yes, dry_run)).await?;
|
||||
Ok(reply)
|
||||
}
|
||||
|
||||
/// Initialize system
|
||||
pub async fn initialize(&self, branch: String) -> Result<String, Box<dyn Error>> {
|
||||
let reply: String = self.proxy.call("initialize", &(branch)).await?;
|
||||
Ok(reply)
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper function to call daemon with fallback to client
|
||||
pub async fn call_daemon_with_fallback<F, T>(
|
||||
daemon_call: F,
|
||||
client_fallback: T,
|
||||
) -> Result<String, Box<dyn Error>>
|
||||
where
|
||||
F: FnOnce(&DaemonClient) -> std::pin::Pin<Box<dyn std::future::Future<Output = Result<String, Box<dyn Error>>> + Send>>,
|
||||
T: FnOnce() -> std::pin::Pin<Box<dyn std::future::Future<Output = Result<String, Box<dyn Error>>> + Send>>,
|
||||
{
|
||||
match DaemonClient::new().await {
|
||||
Ok(client) => {
|
||||
match daemon_call(&client).await {
|
||||
Ok(result) => Ok(result),
|
||||
Err(e) => {
|
||||
eprintln!("Warning: Daemon call failed: {}. Falling back to client...", e);
|
||||
client_fallback().await
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("Warning: Could not connect to daemon: {}. Falling back to client...", e);
|
||||
client_fallback().await
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue