atproto blogging
at main 216 lines 6.7 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: com.atproto.sync.getLatestCommit 4// 5// This file was automatically generated from Lexicon schemas. 6// Any manual changes will be overwritten on the next regeneration. 7 8#[derive( 9 serde::Serialize, 10 serde::Deserialize, 11 Debug, 12 Clone, 13 PartialEq, 14 Eq, 15 jacquard_derive::IntoStatic 16)] 17#[serde(rename_all = "camelCase")] 18pub struct GetLatestCommit<'a> { 19 #[serde(borrow)] 20 pub did: jacquard_common::types::string::Did<'a>, 21} 22 23pub mod get_latest_commit_state { 24 25 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 26 #[allow(unused)] 27 use ::core::marker::PhantomData; 28 mod sealed { 29 pub trait Sealed {} 30 } 31 /// State trait tracking which required fields have been set 32 pub trait State: sealed::Sealed { 33 type Did; 34 } 35 /// Empty state - all required fields are unset 36 pub struct Empty(()); 37 impl sealed::Sealed for Empty {} 38 impl State for Empty { 39 type Did = Unset; 40 } 41 ///State transition - sets the `did` field to Set 42 pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>); 43 impl<S: State> sealed::Sealed for SetDid<S> {} 44 impl<S: State> State for SetDid<S> { 45 type Did = Set<members::did>; 46 } 47 /// Marker types for field names 48 #[allow(non_camel_case_types)] 49 pub mod members { 50 ///Marker type for the `did` field 51 pub struct did(()); 52 } 53} 54 55/// Builder for constructing an instance of this type 56pub struct GetLatestCommitBuilder<'a, S: get_latest_commit_state::State> { 57 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 58 __unsafe_private_named: ( 59 ::core::option::Option<jacquard_common::types::string::Did<'a>>, 60 ), 61 _phantom: ::core::marker::PhantomData<&'a ()>, 62} 63 64impl<'a> GetLatestCommit<'a> { 65 /// Create a new builder for this type 66 pub fn new() -> GetLatestCommitBuilder<'a, get_latest_commit_state::Empty> { 67 GetLatestCommitBuilder::new() 68 } 69} 70 71impl<'a> GetLatestCommitBuilder<'a, get_latest_commit_state::Empty> { 72 /// Create a new builder with all fields unset 73 pub fn new() -> Self { 74 GetLatestCommitBuilder { 75 _phantom_state: ::core::marker::PhantomData, 76 __unsafe_private_named: (None,), 77 _phantom: ::core::marker::PhantomData, 78 } 79 } 80} 81 82impl<'a, S> GetLatestCommitBuilder<'a, S> 83where 84 S: get_latest_commit_state::State, 85 S::Did: get_latest_commit_state::IsUnset, 86{ 87 /// Set the `did` field (required) 88 pub fn did( 89 mut self, 90 value: impl Into<jacquard_common::types::string::Did<'a>>, 91 ) -> GetLatestCommitBuilder<'a, get_latest_commit_state::SetDid<S>> { 92 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 93 GetLatestCommitBuilder { 94 _phantom_state: ::core::marker::PhantomData, 95 __unsafe_private_named: self.__unsafe_private_named, 96 _phantom: ::core::marker::PhantomData, 97 } 98 } 99} 100 101impl<'a, S> GetLatestCommitBuilder<'a, S> 102where 103 S: get_latest_commit_state::State, 104 S::Did: get_latest_commit_state::IsSet, 105{ 106 /// Build the final struct 107 pub fn build(self) -> GetLatestCommit<'a> { 108 GetLatestCommit { 109 did: self.__unsafe_private_named.0.unwrap(), 110 } 111 } 112} 113 114#[jacquard_derive::lexicon] 115#[derive( 116 serde::Serialize, 117 serde::Deserialize, 118 Debug, 119 Clone, 120 PartialEq, 121 Eq, 122 jacquard_derive::IntoStatic 123)] 124#[serde(rename_all = "camelCase")] 125pub struct GetLatestCommitOutput<'a> { 126 #[serde(borrow)] 127 pub cid: jacquard_common::types::string::Cid<'a>, 128 pub rev: jacquard_common::types::string::Tid, 129} 130 131#[jacquard_derive::open_union] 132#[derive( 133 serde::Serialize, 134 serde::Deserialize, 135 Debug, 136 Clone, 137 PartialEq, 138 Eq, 139 thiserror::Error, 140 miette::Diagnostic, 141 jacquard_derive::IntoStatic 142)] 143#[serde(tag = "error", content = "message")] 144#[serde(bound(deserialize = "'de: 'a"))] 145pub enum GetLatestCommitError<'a> { 146 #[serde(rename = "RepoNotFound")] 147 RepoNotFound(std::option::Option<jacquard_common::CowStr<'a>>), 148 #[serde(rename = "RepoTakendown")] 149 RepoTakendown(std::option::Option<jacquard_common::CowStr<'a>>), 150 #[serde(rename = "RepoSuspended")] 151 RepoSuspended(std::option::Option<jacquard_common::CowStr<'a>>), 152 #[serde(rename = "RepoDeactivated")] 153 RepoDeactivated(std::option::Option<jacquard_common::CowStr<'a>>), 154} 155 156impl core::fmt::Display for GetLatestCommitError<'_> { 157 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 158 match self { 159 Self::RepoNotFound(msg) => { 160 write!(f, "RepoNotFound")?; 161 if let Some(msg) = msg { 162 write!(f, ": {}", msg)?; 163 } 164 Ok(()) 165 } 166 Self::RepoTakendown(msg) => { 167 write!(f, "RepoTakendown")?; 168 if let Some(msg) = msg { 169 write!(f, ": {}", msg)?; 170 } 171 Ok(()) 172 } 173 Self::RepoSuspended(msg) => { 174 write!(f, "RepoSuspended")?; 175 if let Some(msg) = msg { 176 write!(f, ": {}", msg)?; 177 } 178 Ok(()) 179 } 180 Self::RepoDeactivated(msg) => { 181 write!(f, "RepoDeactivated")?; 182 if let Some(msg) = msg { 183 write!(f, ": {}", msg)?; 184 } 185 Ok(()) 186 } 187 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), 188 } 189 } 190} 191 192/// Response type for 193///com.atproto.sync.getLatestCommit 194pub struct GetLatestCommitResponse; 195impl jacquard_common::xrpc::XrpcResp for GetLatestCommitResponse { 196 const NSID: &'static str = "com.atproto.sync.getLatestCommit"; 197 const ENCODING: &'static str = "application/json"; 198 type Output<'de> = GetLatestCommitOutput<'de>; 199 type Err<'de> = GetLatestCommitError<'de>; 200} 201 202impl<'a> jacquard_common::xrpc::XrpcRequest for GetLatestCommit<'a> { 203 const NSID: &'static str = "com.atproto.sync.getLatestCommit"; 204 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; 205 type Response = GetLatestCommitResponse; 206} 207 208/// Endpoint type for 209///com.atproto.sync.getLatestCommit 210pub struct GetLatestCommitRequest; 211impl jacquard_common::xrpc::XrpcEndpoint for GetLatestCommitRequest { 212 const PATH: &'static str = "/xrpc/com.atproto.sync.getLatestCommit"; 213 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; 214 type Request<'de> = GetLatestCommit<'de>; 215 type Response = GetLatestCommitResponse; 216}