1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
// Author: D.S. Ljungmark <spider@skuggor.se>, Modio AB
// SPDX-License-Identifier: MIT
use zbus::{dbus_proxy, Result};
mod types;
pub use types::{Measure, Measures};
pub use types::{PreparedPoint, Tid};
pub use types::{Transaction, Transactions};
#[dbus_proxy(
interface = "se.modio.logger.fsipc",
default_service = "se.modio.logger",
default_path = "/se/modio/logger"
)]
/// The fsipc trait documents the Legacy modio logger "fsipc" setup.
/// This api is organically grown like a midden heap,
/// and some design choices were made simply to avoid touching
/// some parts of the code.
///
/// As such, the return types and data structures used are sometimes
/// misgiving, and other times totally wrong for a useful situation.
///
/// There aren't any big dragons here, however the rats may gnaw on
/// your bones if you're careless.
trait fsipc {
/// GetBoxid method
fn get_boxid(&self) -> Result<String>;
/// Retrieve method
fn retrieve(&self, key: &str) -> Result<Measure>;
/// RetrieveAll method
fn retrieve_all(&self) -> Result<Measures>;
/// Store method
fn store(&self, key: &str, value: &str) -> Result<()>;
/// StoreWithTime method
fn store_with_time(&self, key: &str, value: &str, when: u64) -> Result<()>;
/// Signal passed when new measures are added
#[dbus_proxy(signal)]
fn store_signal(&self, key: &str, value: &str, when: u64) -> zbus::Result<()>;
/// Signal passed when a new Transaction is added.
#[dbus_proxy(signal)]
fn transaction_added(&self, key: &str) -> zbus::Result<()>;
/// TransactionAdd method
fn transaction_add(&self, key: &str, expected: &str, target: &str, token: &str) -> Result<()>;
/// TransactionFail method
fn transaction_fail(&self, t_id: Tid) -> Result<()>;
/// TransactionGet method
fn transaction_get(&self, keyspace: &str) -> Result<Transactions>;
/// TransactionPass method
fn transaction_pass(&self, t_id: Tid) -> Result<()>;
/// ValidKey method
fn valid_key(&self, key: &str) -> Result<bool>;
/// Ping method
/// ( may not be implemented)
fn ping(&self) -> Result<String>;
/// Done method
/// (may not be implemented)
fn done(&self) -> Result<()>;
/// Prepare datapoints for delivery
fn prepare_datapoints(&self, maximum: u32) -> Result<Vec<PreparedPoint>>;
/// Prepare datapoints for delivery
fn prepare_modio_datapoints(&self, maximum: u32) -> Result<Vec<PreparedPoint>>;
/// Remove a batch of prepared datapoints
fn remove_prepared(&self, items: Vec<i64>) -> Result<()>;
}
#[cfg(test)]
mod tests {
use super::fsipcProxy;
#[async_std::test]
async fn it_works() {
let conn = zbus::Connection::session().await.unwrap();
let proxy = fsipcProxy::builder(&conn)
.destination("se.modio.logger.TestFsIPC")
.unwrap()
.path("/se/modio/logger")
.unwrap()
.build()
.await;
assert!(proxy.is_ok());
}
}