#[cfg(feature = "derive")]
use entid::{Prefix, UlidEntityId, UuidEntityId};
#[cfg(feature = "derive")]
#[derive(Prefix)]
#[entid(prefix = "user", delimiter = "_")]
struct User;
#[cfg(feature = "derive")]
#[derive(Prefix)]
#[entid(prefix = "post", delimiter = "-")]
struct Post;
#[cfg(feature = "derive")]
#[derive(Debug, Prefix)]
#[entid(prefix = "comment")]
struct Comment;
#[cfg(feature = "derive")]
fn main() {
let user_id = UuidEntityId::<User>::generate();
println!("User ID: {}", user_id); assert!(user_id.to_string().starts_with("user_"));
let post_id = UlidEntityId::<Post>::generate();
println!("Post ID: {}", post_id); assert!(post_id.to_string().starts_with("post-"));
let comment_id_str = format!("comment_{}", uuid::Uuid::new_v4());
let comment_id = UuidEntityId::<Comment>::new(&comment_id_str).unwrap();
println!("Comment ID: {}", comment_id);
assert!(user_id.to_string().starts_with("user_"));
assert!(post_id.to_string().starts_with("post-"));
assert!(comment_id.as_str().starts_with("comment_"));
}
#[cfg(not(feature = "derive"))]
fn main() {
println!("This example requires the 'derive' feature to be enabled.");
println!("Run with: cargo run --example derive_macros --features derive");
}