A better Rust ATProto crate
at lifetimes 4.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 bon::Builder, 16 jacquard_derive::IntoStatic 17)] 18#[builder(start_fn = new)] 19#[serde(rename_all = "camelCase")] 20pub struct GetLatestCommit<'a> { 21 #[serde(borrow)] 22 pub did: jacquard_common::types::string::Did<'a>, 23} 24 25#[jacquard_derive::lexicon] 26#[derive( 27 serde::Serialize, 28 serde::Deserialize, 29 Debug, 30 Clone, 31 PartialEq, 32 Eq, 33 jacquard_derive::IntoStatic 34)] 35#[serde(rename_all = "camelCase")] 36pub struct GetLatestCommitOutput<'a> { 37 #[serde(borrow)] 38 pub cid: jacquard_common::types::string::Cid<'a>, 39 pub rev: jacquard_common::types::string::Tid, 40} 41 42#[jacquard_derive::open_union] 43#[derive( 44 serde::Serialize, 45 serde::Deserialize, 46 Debug, 47 Clone, 48 PartialEq, 49 Eq, 50 thiserror::Error, 51 miette::Diagnostic 52)] 53#[serde(tag = "error", content = "message")] 54#[serde(bound(deserialize = "'de: 'a"))] 55pub enum GetLatestCommitError<'a> { 56 #[serde(rename = "RepoNotFound")] 57 RepoNotFound(std::option::Option<String>), 58 #[serde(rename = "RepoTakendown")] 59 RepoTakendown(std::option::Option<String>), 60 #[serde(rename = "RepoSuspended")] 61 RepoSuspended(std::option::Option<String>), 62 #[serde(rename = "RepoDeactivated")] 63 RepoDeactivated(std::option::Option<String>), 64} 65 66impl std::fmt::Display for GetLatestCommitError<'_> { 67 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 68 match self { 69 Self::RepoNotFound(msg) => { 70 write!(f, "RepoNotFound")?; 71 if let Some(msg) = msg { 72 write!(f, ": {}", msg)?; 73 } 74 Ok(()) 75 } 76 Self::RepoTakendown(msg) => { 77 write!(f, "RepoTakendown")?; 78 if let Some(msg) = msg { 79 write!(f, ": {}", msg)?; 80 } 81 Ok(()) 82 } 83 Self::RepoSuspended(msg) => { 84 write!(f, "RepoSuspended")?; 85 if let Some(msg) = msg { 86 write!(f, ": {}", msg)?; 87 } 88 Ok(()) 89 } 90 Self::RepoDeactivated(msg) => { 91 write!(f, "RepoDeactivated")?; 92 if let Some(msg) = msg { 93 write!(f, ": {}", msg)?; 94 } 95 Ok(()) 96 } 97 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), 98 } 99 } 100} 101 102impl jacquard_common::IntoStatic for GetLatestCommitError<'_> { 103 type Output = GetLatestCommitError<'static>; 104 fn into_static(self) -> Self::Output { 105 match self { 106 GetLatestCommitError::RepoNotFound(v) => { 107 GetLatestCommitError::RepoNotFound(v.into_static()) 108 } 109 GetLatestCommitError::RepoTakendown(v) => { 110 GetLatestCommitError::RepoTakendown(v.into_static()) 111 } 112 GetLatestCommitError::RepoSuspended(v) => { 113 GetLatestCommitError::RepoSuspended(v.into_static()) 114 } 115 GetLatestCommitError::RepoDeactivated(v) => { 116 GetLatestCommitError::RepoDeactivated(v.into_static()) 117 } 118 GetLatestCommitError::Unknown(v) => { 119 GetLatestCommitError::Unknown(v.into_static()) 120 } 121 } 122 } 123} 124 125///Response type for 126///com.atproto.sync.getLatestCommit 127pub struct GetLatestCommitResponse; 128impl jacquard_common::xrpc::XrpcResp for GetLatestCommitResponse { 129 const NSID: &'static str = "com.atproto.sync.getLatestCommit"; 130 const ENCODING: &'static str = "application/json"; 131 type Output<'de> = GetLatestCommitOutput<'de>; 132 type Err<'de> = GetLatestCommitError<'de>; 133} 134 135impl<'de> jacquard_common::xrpc::XrpcRequest<'de> for GetLatestCommit<'de> { 136 const NSID: &'static str = "com.atproto.sync.getLatestCommit"; 137 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; 138 type Response = GetLatestCommitResponse; 139} 140 141///Endpoint type for 142///com.atproto.sync.getLatestCommit 143pub struct GetLatestCommitRequest; 144impl jacquard_common::xrpc::XrpcEndpoint for GetLatestCommitRequest { 145 const PATH: &'static str = "/xrpc/com.atproto.sync.getLatestCommit"; 146 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; 147 type Request<'de> = GetLatestCommit<'de>; 148 type Response = GetLatestCommitResponse; 149}