Skip to main content

genja_core/
lib.rs

1//! # Genja Core
2//!
3//! A network automation library.
4//!
5//! ## Initialization
6//!
7//! This library does not initialize logging or other global state.
8//! Users must handle initialization in their application.
9//!
10//! ### Example: Basic Setup
11//!
12//! ```no_run
13//! use genja_core::Settings;
14//!
15//! fn main() -> Result<(), Box<dyn std::error::Error>> {
16//!     // Load settings
17//!     let settings = Settings::from_file("config.yaml")?;
18//!
19//!     // Initialize your application with settings
20//!     // ...
21//!
22//!     Ok(())
23//! }
24//! ```
25//!
26//! ### Example: With Logging
27//!
28//! If you want file-based logging, set it up yourself using the config values:
29//!
30//! ```no_run
31//! use genja_core::Settings;
32//! use tracing_subscriber::prelude::*;
33//! use tracing_rolling_file::RollingFileAppender;
34//!
35//! fn main() -> Result<(), Box<dyn std::error::Error>> {
36//!     let settings = Settings::from_file("config.yaml")?;
37//!
38//!     // Set up logging based on settings
39//!     if settings.logging().enabled() {
40//!         let appender = RollingFileAppender::builder()
41//!             .filename(settings.logging().log_file().to_string())
42//!             .condition_max_file_size(settings.logging().file_size())
43//!             .max_filecount(settings.logging().max_file_count())
44//!             .build()?;
45//!
46//!         let (non_blocking, _guard) = appender.get_non_blocking_appender();
47//!
48//!         tracing_subscriber::registry()
49//!             .with(tracing_subscriber::fmt::layer().with_writer(non_blocking))
50//!             .init();
51//!
52//!         // Keep _guard alive for the program duration
53//!         std::mem::forget(_guard); // Or store it somewhere
54//!     }
55//!
56//!     // Your application logic
57//!     Ok(())
58//! }
59//! ```
60
61pub mod errors;
62pub mod inventory;
63pub mod settings;
64pub mod state;
65pub mod task;
66pub mod types;
67
68pub use ::async_trait::async_trait;
69pub use errors::{
70    ConfigLoadError, GenjaError, InventoryFileKind, InventoryLoadError, SshConfigError,
71};
72pub use genja_core_derive::genja_task;
73pub use settings::Settings;
74pub use state::{
75    ConnectionAttemptState, ConnectionFailureKind, ConnectionStatus, HostStatus, State,
76    TaskAttemptState, TaskExecutionKey, TaskFailureKind, TaskStatus,
77};
78pub use types::{CustomTreeMap, NatString};