use std::sync::Arc; use rpc_toolkit::command; use rpc_toolkit::yajrc::RpcError; use crate::context::RecoveryContext; use crate::logs::{display_logs, fetch_logs, LogResponse, LogSource}; use crate::Error; pub const SYSTEMD_UNIT: &'static str = "embassy-init"; #[command(subcommands(error, logs, exit))] pub fn recovery() -> Result<(), Error> { Ok(()) } #[command] pub fn error(#[context] ctx: RecoveryContext) -> Result, Error> { Ok(ctx.error.clone()) } #[command(display(display_logs))] pub async fn logs( #[arg] limit: Option, #[arg] cursor: Option, #[arg] before_flag: Option, ) -> Result { Ok(fetch_logs( LogSource::Service(SYSTEMD_UNIT), limit, cursor, before_flag.unwrap_or(false), ) .await?) } #[command] pub fn exit(#[context] ctx: RecoveryContext) -> Result<(), Error> { ctx.shutdown.send(()).expect("receiver dropped"); }