ih_muse/
lib.rs

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
//! # IH-Muse: *The Common IH-Muse Library for Rust*
//!
//! IH-Muse is a Rust library providing functionality to interact with the IH system,
//! including element registration, metric reporting, and recording/replaying for testing.
//! It's designed to be efficient, scalable, and easy to integrate into your applications.
//!
//! ## **Quickstart**
//!
//! Here's a simple example demonstrating how to use IH-Muse:
//!
//! ```rust,no_run
//! use ih_muse::prelude::*;
//! use std::collections::HashMap;
//!
//! #[tokio::main]
//! async fn main() -> MuseResult<()> {
//!     let config = Config::new(
//!         vec!["http://localhost:8080".to_string()],
//!         ClientType::Poet,
//!         false,
//!         None,
//!         None,
//!         TimestampResolution::Milliseconds,
//!         vec![ElementKindRegistration::new("kind_code", Some("parent_code"), "kind_name", "description")],
//!         vec![MetricDefinition::new("metric_code", "metric_name", "description")],
//!         Some(std::time::Duration::from_secs(60)),
//!         Some(std::time::Duration::from_secs(60)),
//!         3,
//!     )?;
//!
//!     let mut muse = Muse::new(&config)?;
//!     muse.initialize(Some(std::time::Duration::from_secs(5))).await?;
//!
//!     let local_elem_id = muse
//!         .register_element(
//!             "kind_code",
//!             "Element Name".to_string(),
//!             HashMap::new(),
//!             None,
//!         )
//!         .await?;
//!
//!     muse.send_metric(local_elem_id, "metric_code", MetricValue::from(42.0))
//!         .await?;
//!
//!     Ok(())
//! }
//! ```
//!
//! ## **Features**
//!
//! - **Element Registration:** Easily register elements with specific kinds and metadata.
//! - **Metric Reporting:** Send metrics associated with elements to the Muse system.
//! - **Event Recording:** Record events for later analysis or replaying.
//! - **Client Configuration:** Support for different client types (`Poet`, `Mock`).
//!
//! ## **Modules**
//!
//! - [`config`]: Contains configuration structures and enums.
//! - [`muse`]: Main module containing the `Muse` struct.
//! - [`tasks`]: Internal tasks handling background operations.
//!
//! ## **License**
//!
//! This project is licensed under the MIT License.
//!
//! [`config`]: crate::config
//! [`muse`]: crate::muse
//! [`tasks`]: crate::tasks

mod muse;
pub mod prelude;
mod tasks;
pub mod timing;

pub use ih_muse_core::MuseError;
pub use muse::Muse;

/// Polars crate version
pub const VERSION: &str = env!("CARGO_PKG_VERSION");