1use crate::error::Error;
2
3use std::fmt::Display;
4#[derive(serde::Serialize, serde::Deserialize, Debug, Eq, PartialEq, Hash, Clone)]
5#[serde(transparent)]
6pub struct PageId(pub uuid::Uuid);
7
8impl Display for PageId {
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 PageId {
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(PageId(i)),
20 Err(e) => Err(Error::UUID { source: e }),
21 }
22 }
23}