1use crate::error::Error;
2
3use std::fmt::Display;
4
5#[derive(serde::Serialize, serde::Deserialize, Debug, Eq, PartialEq, Hash, Clone)]
6#[serde(transparent)]
7pub struct UserId(pub uuid::Uuid);
8impl Display for UserId {
9 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
10 self.0.fmt(f)
11 }
12}
13
14impl std::str::FromStr for UserId {
15 type Err = Error;
16
17 fn from_str(s: &str) -> Result<Self, Self::Err> {
18 match uuid::Uuid::parse_str(s) {
19 Ok(i) => Ok(UserId(i)),
20 Err(e) => Err(Error::UUID { source: e }),
21 }
22 }
23}