notion_sdk/database/
id.rs

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 DatabaseId(pub uuid::Uuid);
8
9impl Display for DatabaseId {
10    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11        self.0.fmt(f)
12    }
13}
14
15impl std::str::FromStr for DatabaseId {
16    type Err = Error;
17
18    fn from_str(s: &str) -> Result<Self, Self::Err> {
19        match uuid::Uuid::parse_str(s) {
20            Ok(i) => Ok(DatabaseId(i)),
21            Err(e) => Err(Error::UUID { source: e }),
22        }
23    }
24}
25
26#[derive(serde::Serialize, serde::Deserialize, Debug, Eq, PartialEq, Hash, Clone, Default)]
27#[serde(transparent)]
28pub struct PropertyId(pub String);
29
30impl Display for PropertyId {
31    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
32        self.0.fmt(f)
33    }
34}
35
36impl std::str::FromStr for PropertyId {
37    type Err = Error;
38
39    fn from_str(s: &str) -> Result<Self, Self::Err> {
40        Ok(PropertyId(s.to_string()))
41    }
42}