fsipc 0.9.2

fsipc, zbus Proxy for the modio-logger DBus interface
Documentation
// Author: D.S. Ljungmark <spider@skuggor.se>, Modio AB
// SPDX-License-Identifier: MIT
//! # `DBus` interface proxies for: `se.modio.logger`, `se.modio.logger.Logger1`, `se.modio.logger.fsipc`
//!
//! This code was generated by `zbus-xmlgen` `3.0.0` from `DBus` introspection data.
//! Source: `Interface '/se/modio/logger' from service 'se.modio.logger' on session bus`.
//!
//! You may prefer to adapt it, instead of using it verbatim.
//!
//! More information can be found in the
//! [Writing a client proxy](https://dbus.pages.freedesktop.org/zbus/client.html)
//! section of the zbus documentation.
//!
//! This `DBus` object implements
//! [standard `DBus` interfaces](https://dbus.freedesktop.org/doc/dbus-specification.html),
//! (`org.freedesktop.DBus.*`) for which the following zbus proxies can be used:
//!
//! * [`zbus::fdo::PropertiesProxy`]
//! * [`zbus::fdo::PeerProxy`]
//! * [`zbus::fdo::IntrospectableProxy`]
//!
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces.

use serde::Deserialize;
use serde::Serialize;
use std::collections::HashMap;
use zbus::dbus_proxy;
use zbus::zvariant::{DeserializeDict, SerializeDict, Type};

pub type ValueMap = HashMap<u32, String>;

#[derive(Debug, PartialEq, Eq, Type, Serialize, Deserialize)]
pub enum SensorMode {
    ReadOnly,
    ReadWrite,
    WriteOnly,
}

// This type should match the one here:
// https://gitlab.com/ModioAB/modio-logger/-/blob/main/modio-logger/src/types.rs#L108
#[derive(Debug, PartialEq, Eq, DeserializeDict, SerializeDict, Type)]
#[zvariant(signature = "dict")]
pub struct Metadata {
    pub n: String,
    pub u: Option<String>,
    pub name: Option<String>,
    pub description: Option<String>,
    pub value_map: Option<ValueMap>,
    pub mode: Option<SensorMode>,
}

#[dbus_proxy(
    interface = "se.modio.logger.Logger1",
    default_service = "se.modio.logger",
    default_path = "/se/modio/logger"
)]
trait Logger1 {
    /// GetMetadata method
    fn get_metadata(&self, key: &str) -> zbus::Result<Metadata>;

    /// SetMetadataDescription method
    fn set_metadata_description(&self, key: &str, description: &str) -> zbus::Result<()>;

    /// SetMetadataMode method
    fn set_metadata_mode(&self, key: &str, mode: SensorMode) -> zbus::Result<()>;

    /// SetMetadataName method
    fn set_metadata_name(&self, key: &str, name: &str) -> zbus::Result<()>;

    /// SetMetadataUnit method
    fn set_metadata_unit(&self, key: &str, unit: &str) -> zbus::Result<()>;

    /// SetMetadataValueMap method
    fn set_metadata_value_map(&self, key: &str, value_map: ValueMap) -> zbus::Result<()>;

    /// MetadataUpdated signal
    #[dbus_proxy(signal)]
    fn metadata_updated(&self, key: &str) -> zbus::Result<()>;
}