| Crates.io | guardia-rs-urn |
| lib.rs | guardia-rs-urn |
| version | 1.0.0 |
| created_at | 2025-02-23 02:21:46.165997+00 |
| updated_at | 2025-05-16 11:58:51.305294+00 |
| description | This lib provides a command-line tool for generating Uniform Resource Names (URNs) to uniquely identify resources within the Guardia system. |
| homepage | |
| repository | https://github.com/guardiafinance/guardia-rs-urn |
| max_upload_size | |
| id | 1565997 |
| size | 78,129 |
This project provides a library for generating and validating Uniform Resource Names (URNs) to identify resources within the Guardia system.
use guardia_rs_urn::UrnBuilder;
// Generating a URN
let urn = UrnBuilder::new()
.with_organization_id("a5b1d001-3b82-4deb-8602-9463f733646e")
.with_tenant_id("a5b1d001-3b82-4deb-8602-9463f733646e")
.with_product("lke")
.with_entity_type("user")
.with_entity_id("a5b1d001-3b82-4deb-8602-9463f733646e")
.build()?;
println!("Generated URN: {}", urn);
// Parsing an existing URN
let urn_str = "urn:guardia:org:a5b1d001-3b82-4deb-8602-9463f733646e:tenant:a5b1d001-3b82-4deb-8602-9463f733646e:lke:user:a5b1d001-3b82-4deb-8602-9463f733646e";
let parsed_urn = GuardiaUrn::parse(urn_str)?;
// Accessing URN fields
println!("Organization ID: {}", parsed_urn.organization_id.unwrap());
println!("Product: {}", parsed_urn.product.unwrap());
export ORGANIZATION_ID=a5b1d001-3b82-4deb-8602-9463f733646e
export TENANT_ID=a5b1d001-3b82-4deb-8602-9463f733646e
export PRODUCT=lke
export ENTITY_TYPE=user
export ENTITY_ID=a5b1d001-3b82-4deb-8602-9463f733646e
# The URN will be generated automatically when running the program
rail and providerrail, protocol, and provider.
├── src/
│ └── lib.rs # Core implementation
├── tests/
│ ├── cucumber.rs # Test configuration
│ ├── features/ # Cucumber feature files
│ │ ├── urn.feature # Generation tests
│ │ └── urn_parsing.feature # Parsing tests
│ └── steps/ # Step definitions
│ ├── mod.rs
│ ├── builder_steps.rs # Steps for generation
│ └── parser_steps.rs # Steps for parsing
└── Cargo.toml
# Unit tests
cargo test
# Integration tests with Cucumber
cargo test --test cucumber
Contributions are welcome! Please open an issue or submit a pull request for improvements or bug fixes.