Another project
0

Configure Feed

Select the types of activity you want to include in your feed.

at main 1.4 kB View raw
1use serde::{Deserialize, Serialize}; 2 3#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] 4#[serde(deny_unknown_fields)] 5pub struct SchemaVersion { 6 pub major: u32, 7 pub minor: u32, 8} 9 10impl SchemaVersion { 11 #[must_use] 12 pub const fn new(major: u32, minor: u32) -> Self { 13 Self { major, minor } 14 } 15} 16 17impl core::fmt::Display for SchemaVersion { 18 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 19 write!(f, "{}.{}", self.major, self.minor) 20 } 21} 22 23#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] 24#[serde(deny_unknown_fields)] 25pub struct SchemaHeader { 26 pub name: String, 27 pub version: SchemaVersion, 28} 29 30impl SchemaHeader { 31 pub const BONE_DOCUMENT_NAME: &'static str = "bone-document"; 32 pub const BONE_DOCUMENT_MAJOR: u32 = 1; 33 pub const BONE_DOCUMENT_MINOR: u32 = 4; 34 35 #[must_use] 36 pub fn bone_document() -> Self { 37 Self { 38 name: Self::BONE_DOCUMENT_NAME.to_owned(), 39 version: SchemaVersion::new(Self::BONE_DOCUMENT_MAJOR, Self::BONE_DOCUMENT_MINOR), 40 } 41 } 42 43 #[must_use] 44 pub fn is_bone_document(&self) -> bool { 45 self.name == Self::BONE_DOCUMENT_NAME 46 } 47} 48 49impl core::fmt::Display for SchemaHeader { 50 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 51 write!(f, "{} v{}", self.name, self.version) 52 } 53}