rust_mcp_sdk/id_generator/uuid_generator.rs
1use crate::mcp_traits::IdGenerator;
2use uuid::Uuid;
3
4/// An [`IdGenerator`] implementation that uses UUID v4 to create unique identifiers.
5///
6/// This generator produces random UUIDs (version 4), which are highly unlikely
7/// to collide and difficult to predict. It is therefore well-suited for
8/// generating identifiers such as `SessionId` or other values where uniqueness is important.
9pub struct UuidGenerator;
10
11impl<T> IdGenerator<T> for UuidGenerator
12where
13 T: From<String>,
14{
15 fn generate(&self) -> T {
16 T::from(Uuid::new_v4().to_string())
17 }
18}