feat(ipc): zbus-proxy Power1/Settings1

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Alexander <akotenev2003@gmail.com>
This commit is contained in:
2026-06-24 12:11:11 +03:00
parent 0d630dde84
commit d8eebc96ce
2 changed files with 54 additions and 0 deletions
+2
View File
@@ -4,7 +4,9 @@
pub mod error;
pub mod names;
pub mod proxy;
pub mod types;
pub use error::Error;
pub use proxy::{Power1Proxy, Settings1Proxy};
pub use types::{IgnitionState, PowerSource, PowerState, ShutdownReason};
+52
View File
@@ -0,0 +1,52 @@
//! Клиентские `#[proxy]`-трейты (ipc §3). zbus генерит `Power1Proxy` / `Settings1Proxy`.
//! Enum-значения передаются строками (`types`); `Settings` — D-Bus variant (`zvariant::Value`/`OwnedValue`).
use zbus::proxy;
use zbus::zvariant::{OwnedValue, Value};
/// `ru.shturman.Power1` — питание/жизненный цикл (домен B).
#[proxy(
interface = "ru.shturman.Power1",
default_service = "ru.shturman.Power",
default_path = "/ru/shturman/Power"
)]
pub trait Power1 {
/// Текущее состояние (enum-строка `PowerState`).
fn get_power_state(&self) -> zbus::Result<String>;
/// Внутренний запрос сна (в v0-стабе — no-op).
fn request_sleep(&self) -> zbus::Result<()>;
#[zbus(property)]
fn ignition_state(&self) -> zbus::Result<String>;
#[zbus(property)]
fn uptime(&self) -> zbus::Result<u64>;
#[zbus(property)]
fn power_source(&self) -> zbus::Result<String>;
#[zbus(signal)]
fn acc_changed(&self, on: bool) -> zbus::Result<()>;
#[zbus(signal)]
fn shutdown_imminent(&self, seconds: u32, reason: String) -> zbus::Result<()>;
#[zbus(signal)]
fn shutdown_aborted(&self) -> zbus::Result<()>;
#[zbus(signal)]
fn sleep(&self) -> zbus::Result<()>;
#[zbus(signal)]
fn wake(&self) -> zbus::Result<()>;
}
/// `ru.shturman.Settings1` — конфигурация и состояние.
#[proxy(
interface = "ru.shturman.Settings1",
default_service = "ru.shturman.Settings",
default_path = "/ru/shturman/Settings"
)]
pub trait Settings1 {
fn get(&self, key: &str) -> zbus::Result<OwnedValue>;
fn set(&self, key: &str, value: &Value<'_>) -> zbus::Result<()>;
fn list(&self, prefix: &str) -> zbus::Result<Vec<String>>;
fn reset(&self, key: &str) -> zbus::Result<()>;
#[zbus(signal)]
fn changed(&self, key: String, value: OwnedValue) -> zbus::Result<()>;
}