use typed_oid::error::*;
#[cfg(not(feature = "uuid_v4"))]
fn oid_v4() -> Result<()> {
println!("Feature uuid_v4 is not enabled");
Ok(())
}
#[cfg(not(feature = "uuid_v7"))]
fn oid_v7() -> Result<()> {
println!("Feature uuid_v7 is not enabled");
Ok(())
}
fn main() -> Result<()> {
oid_v4()?;
println!("---------------------");
oid_v7()?;
Ok(())
}
#[cfg(feature = "uuid_v4")]
fn oid_v4() -> Result<()> {
use typed_oid::OidStr;
use uuid::Uuid;
let oid = OidStr::new_v4("EXA")?;
println!("OidStr from UUIDv4: {oid}");
let oid: OidStr = "EXA-4GKFGPRVND4QT3PDR90PDKF66O".parse()?;
println!("OidStr from string: {oid}");
let oid = OidStr::with_uuid(
"EXA",
"b3cfdafa-3fec-41e2-82bf-ff881131abf1"
.parse::<Uuid>()
.unwrap(),
)?;
println!("OidStr from raw parts: {oid}");
println!("Components of {oid}:");
println!("\tPrefix: {}", oid.prefix());
println!("\tValue: {}", oid.value());
println!("\tUUID: {}", oid.uuid());
Ok(())
}
#[cfg(feature = "uuid_v7")]
fn oid_v7() -> Result<()> {
use typed_oid::OidStr;
use uuid::Uuid;
let oid = OidStr::new_v7_now("EXA")?;
println!("OidStr from UUIDv7: {oid}");
let oid: OidStr = "EXA-066F28J3RDQ33EB4QM8LVP0TGK".parse()?;
println!("OidStr from string: {oid}");
let oid = OidStr::with_uuid(
"EXA",
"0185e030-ffcf-75fa-a12a-ae8549bd7600".parse::<Uuid>()?,
)?;
println!("OidStr from raw parts: {oid}");
println!("Components of {oid}:");
println!("\tPrefix: {}", oid.prefix());
println!("\tValue: {}", oid.value());
println!("\tUUID: {}", oid.uuid());
Ok(())
}