For most Rust projects, the standard answer is the uuid crate. The main setup step is enabling the right features in Cargo.toml. If your code only needs UUID v4 generation and string formatting, keep the dependency narrow and explicit.
[dependencies]
uuid = { version = "1", features = ["v4", "fast-rng", "serde"] }
This is a practical default for many services. The v4 feature enables random UUID generation. serde is useful if UUIDs move through JSON payloads, config, or message formats. fast-rng can improve performance in some workloads, though the right choice depends on your runtime expectations and how often IDs are created.
If you do not need serialization, remove serde. If the project does not need application-side generation, you may not need the v4 feature at all. This matters in Rust because dependency features are part of the build surface. Keep them intentional.
In application code, the usual generation pattern is straightforward:
use uuid::Uuid;
let id = Uuid::new_v4();
println!("{}", id);
That simplicity is useful, but it should not hide the main decision. Adding the crate is the easy part. Choosing where UUID v4 belongs in your system is the harder part.