atproto blogging
at main 122 lines 3.2 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: com.atproto.sync.defs 4// 5// This file was automatically generated from Lexicon schemas. 6// Any manual changes will be overwritten on the next regeneration. 7 8pub mod get_blob; 9pub mod get_blocks; 10pub mod get_checkout; 11pub mod get_head; 12pub mod get_host_status; 13pub mod get_latest_commit; 14pub mod get_record; 15pub mod get_repo; 16pub mod get_repo_status; 17pub mod list_blobs; 18pub mod list_hosts; 19pub mod list_repos; 20pub mod list_repos_by_collection; 21pub mod notify_of_update; 22pub mod request_crawl; 23 24#[cfg(feature = "streaming")] 25pub mod subscribe_repos; 26 27#[derive(Debug, Clone, PartialEq, Eq, Hash)] 28pub enum HostStatus<'a> { 29 Active, 30 Idle, 31 Offline, 32 Throttled, 33 Banned, 34 Other(jacquard_common::CowStr<'a>), 35} 36 37impl<'a> HostStatus<'a> { 38 pub fn as_str(&self) -> &str { 39 match self { 40 Self::Active => "active", 41 Self::Idle => "idle", 42 Self::Offline => "offline", 43 Self::Throttled => "throttled", 44 Self::Banned => "banned", 45 Self::Other(s) => s.as_ref(), 46 } 47 } 48} 49 50impl<'a> From<&'a str> for HostStatus<'a> { 51 fn from(s: &'a str) -> Self { 52 match s { 53 "active" => Self::Active, 54 "idle" => Self::Idle, 55 "offline" => Self::Offline, 56 "throttled" => Self::Throttled, 57 "banned" => Self::Banned, 58 _ => Self::Other(jacquard_common::CowStr::from(s)), 59 } 60 } 61} 62 63impl<'a> From<String> for HostStatus<'a> { 64 fn from(s: String) -> Self { 65 match s.as_str() { 66 "active" => Self::Active, 67 "idle" => Self::Idle, 68 "offline" => Self::Offline, 69 "throttled" => Self::Throttled, 70 "banned" => Self::Banned, 71 _ => Self::Other(jacquard_common::CowStr::from(s)), 72 } 73 } 74} 75 76impl<'a> AsRef<str> for HostStatus<'a> { 77 fn as_ref(&self) -> &str { 78 self.as_str() 79 } 80} 81 82impl<'a> core::fmt::Display for HostStatus<'a> { 83 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 84 write!(f, "{}", self.as_str()) 85 } 86} 87 88impl<'a> serde::Serialize for HostStatus<'a> { 89 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> 90 where 91 S: serde::Serializer, 92 { 93 serializer.serialize_str(self.as_str()) 94 } 95} 96 97impl<'de, 'a> serde::Deserialize<'de> for HostStatus<'a> 98where 99 'de: 'a, 100{ 101 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> 102 where 103 D: serde::Deserializer<'de>, 104 { 105 let s = <&'de str>::deserialize(deserializer)?; 106 Ok(Self::from(s)) 107 } 108} 109 110impl jacquard_common::IntoStatic for HostStatus<'_> { 111 type Output = HostStatus<'static>; 112 fn into_static(self) -> Self::Output { 113 match self { 114 HostStatus::Active => HostStatus::Active, 115 HostStatus::Idle => HostStatus::Idle, 116 HostStatus::Offline => HostStatus::Offline, 117 HostStatus::Throttled => HostStatus::Throttled, 118 HostStatus::Banned => HostStatus::Banned, 119 HostStatus::Other(v) => HostStatus::Other(v.into_static()), 120 } 121 } 122}