Crates.io | acton-ern |
lib.rs | acton-ern |
version | |
source | src |
created_at | 2024-10-03 23:22:03.639668+00 |
updated_at | 2025-05-08 03:47:02.104479+00 |
description | A Rust library for handling Entity Resource Names (ERNs), providing type-safe, hierarchical, and k-sortable resource identifiers for distributed systems and more. |
homepage | |
repository | https://github.com/govcraft/acton-ern |
max_upload_size | |
id | 1395798 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Acton ERN provides a standardized approach for uniquely identifying and managing resources across services, partitions, and hierarchies in distributed systems.
Implement a consistent, type-safe resource naming scheme that scales with your system.
In distributed systems, resources are scattered across multiple services, databases, and storage systems. Without a consistent naming scheme:
Acton ERN addresses these issues by providing:
Add Acton ERN to your project:
[dependencies]
acton-ern = "1.0.0"
use acton_ern::prelude::*;
// Create a time-ordered, sortable ERN
let ern = ErnBuilder::new()
.with::<Domain>("my-app")?
.with::<Category>("users")?
.with::<Account>("tenant123")?
.with::<EntityRoot>("profile")?
.with::<Part>("settings")?
.build()?;
// The resulting ERN will look like:
// ern:my-app:users:tenant123:profile_01h9xz7n2e5p6q8r3t1u2v3w4x/settings
use acton_ern::prelude::*;
// Parse an ERN from a string
let ern_str = "ern:my-app:users:tenant123:profile_01h9xz7n2e5p6q8r3t1u2v3w4x/settings";
let parsed_ern = ErnParser::new(ern_str.to_string()).parse()?;
// Access components
println!("Domain: {}", parsed_ern.domain);
println!("Category: {}", parsed_ern.category);
println!("Account: {}", parsed_ern.account);
println!("Root: {}", parsed_ern.root);
println!("Parts: {}", parsed_ern.parts);
Acton ERN supports different ID types for different use cases:
// Time-ordered ID (sortable by creation time)
let time_ern: Ern = ErnBuilder::new()
.with::<Domain>("my-app")?
.with::<Category>("events")?
.with::<Account>("tenant123")?
.with::<EntityRoot>("log")?
.build()?;
// Content-addressable ID (same content = same ID)
let content_ern: Ern = ErnBuilder::new()
.with::<Domain>("my-app")?
.with::<Category>("documents")?
.with::<Account>("tenant123")?
.with::<SHA1Name>("report-2023-q4")?
.build()?;
Acton ERN includes optional features:
[dependencies]
acton-ern = { version = "1.0.0", features = ["serde", "async"] }
// Check if one ERN is a child of another
if child_ern.is_child_of(&parent_ern) {
println!("Child resource found.");
}
// Get the parent of an ERN
if let Some(parent) = child_ern.parent() {
println!("Parent: {}", parent);
}
// Combine two ERNs (appends the parts)
let combined_ern = base_ern + extension_ern;
Acton ERN 1.0.0 Release
The 1.0.0 release includes all core functionality, comprehensive testing, and production-ready features. See the CHANGELOG.md for details on what's included in this release.
This project is licensed under either of:
at your option.