| Crates.io | atoman |
| lib.rs | atoman |
| version | 0.2.0 |
| created_at | 2026-01-01 03:59:10.331166+00 |
| updated_at | 2026-01-16 20:22:30.647304+00 |
| description | This library provides a static data that can be accessed safely and concurrently from any part of your program |
| homepage | |
| repository | https://github.com/fuderis/rs-atoman |
| max_upload_size | |
| id | 2015716 |
| size | 47,120 |
Atoman is a Rust library for safe concurrent access to static asynchronous data across your application. It provides atomic flags and state wrappers with async setters, getters, and locking mechanisms, bridging synchronous static variables with async runtimes like Tokio.
Global configuration management with file-based persistence (TOML/JSON).
Structured logging with async-safe output to files.
Feature flags and shared state in async applications.
Data is stored in Arc for zero-copy access and thread safety.
use atoman::prelude::*;
static IS_ACTIVE: Flag = Flag::new();
#[tokio::main]
async fn main() {
assert_eq!(IS_ACTIVE.get(), false);
assert!(IS_ACTIVE.is_false());
IS_ACTIVE.set(true);
assert_eq!(IS_ACTIVE.get(), true);
IS_ACTIVE.swap(false).await;
assert_eq!(IS_ACTIVE.get(), false);
}
use atoman::prelude::*;
static CONFIG: State<Config> = State::new();
#[derive(Default, Clone)]
pub struct Config {
pub count: i32,
}
#[tokio::main]
async fn main() {
CONFIG.set(Config { count: 10, }).await;
assert_eq!(CONFIG.get().await.count, 10);
CONFIG.map(|cfg| cfg.count = 20).await;
assert_eq!(CONFIG.get().await.count, 20);
CONFIG.lock().await.count = 30;
assert_eq!(CONFIG.get().await.count, 30);
}
use atoman::prelude::*;
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
struct Person {
name: String,
age: u32
}
impl Default for Person {
fn default() -> Self {
Self {
name: "Bob".to_owned(),
age: 23
}
}
}
#[tokio::main]
async fn main() -> Result<()> {
let mut cfg = Config::<Person>::new(".test/person.toml")?;
assert_eq!(cfg.name, "Bob");
assert_eq!(cfg.age, 23);
cfg.age = 24;
assert_eq!(cfg.age, 24);
Ok(())
}
use atoman::prelude::*;
#[tokio::main]
async fn main() -> Result<()> {
Logger::init(".test/logs", 20)?;
info!("Hello, World!");
Ok(())
}
This library distributed under the MIT license.
You can contact me via GitHub or send a message to my telegram @fuderis. This library is actively evolving, and your suggestions and feedback are always welcome!