Skip to main content

thingvellir/upstreams/
traits.rs

1/// Trait to convert any type to a "String" primary key.
2///
3/// Implemented by default for any T that can be converted to a string
4/// using [`std::string::ToString`].
5pub trait ToPrimaryKey {
6    /// Converts the struct to a string for usage as a primary key in a data store.
7    fn to_primary_key(&self) -> String;
8}
9
10impl<T> ToPrimaryKey for T
11where
12    T: std::string::ToString,
13{
14    fn to_primary_key(&self) -> String {
15        self.to_string()
16    }
17}