diff options
author | 2021-05-15 10:01:03 -0700 | |
---|---|---|
committer | 2021-05-15 10:01:03 -0700 | |
commit | 371a3e49ffe52c2684030f4d3cb669a3aac2b3ca (patch) | |
tree | 8d624c21a3faf2cf437a89b1102d7be25fa28fea /src/models.rs | |
parent | d18843ab949e803e25c48f514b4e25244477c731 (diff) | |
download | notion-371a3e49ffe52c2684030f4d3cb669a3aac2b3ca.tar.gz notion-371a3e49ffe52c2684030f4d3cb669a3aac2b3ca.tar.zst notion-371a3e49ffe52c2684030f4d3cb669a3aac2b3ca.zip |
adding basic property filters
Diffstat (limited to 'src/models.rs')
-rw-r--r-- | src/models.rs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/models.rs b/src/models.rs index 4500cc0..bb1ba42 100644 --- a/src/models.rs +++ b/src/models.rs @@ -8,8 +8,10 @@ use crate::models::text::RichText; use serde::{Deserialize, Serialize}; use std::collections::HashMap; +use crate::Identifiable; pub use chrono::{DateTime, Utc}; pub use serde_json::value::Number; +use std::fmt::{Display, Formatter}; #[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Copy, Clone)] #[serde(rename_all = "lowercase")] @@ -29,12 +31,20 @@ impl DatabaseId { } } -impl AsRef<DatabaseId> for DatabaseId { - fn as_ref(&self) -> &Self { +impl Identifiable for DatabaseId { + type Type = DatabaseId; + + fn id(&self) -> &Self::Type { self } } +impl Display for DatabaseId { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + self.0.fmt(f) + } +} + /// Represents a Notion Database /// See https://developers.notion.com/reference/database #[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Clone)] @@ -57,8 +67,10 @@ pub struct Database { properties: HashMap<String, PropertyConfiguration>, } -impl AsRef<DatabaseId> for Database { - fn as_ref(&self) -> &DatabaseId { +impl Identifiable for Database { + type Type = DatabaseId; + + fn id(&self) -> &Self::Type { &self.id } } |