define_registry

Macro define_registry 

Source
macro_rules! define_registry {
    ($name:ident) => { ... };
}
Expand description

Creates a singleton registry module with ergonomic free functions.

The macro generates a module containing storage, tracing infrastructure, and a private Api struct implementing RegistryApi.

ยงExample

use singleton_registry::define_registry;
use std::sync::Arc;

// Create registries - each is isolated
define_registry!(global);
define_registry!(cache);

// Register and retrieve values
global::register(42i32);
cache::register("redis".to_string());

let num: Arc<i32> = global::get().unwrap();
let msg: Arc<String> = cache::get().unwrap();

assert_eq!(*num, 42);
assert_eq!(&**msg, "redis");