atproto blogging
at main 216 lines 6.7 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: sh.weaver.notebook.getBookEntry 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 GetBookEntry<'a> { 19 ///(default: 0, min: 0) 20 #[serde(skip_serializing_if = "std::option::Option::is_none")] 21 pub index: std::option::Option<i64>, 22 #[serde(borrow)] 23 pub notebook: jacquard_common::types::string::AtUri<'a>, 24} 25 26pub mod get_book_entry_state { 27 28 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 29 #[allow(unused)] 30 use ::core::marker::PhantomData; 31 mod sealed { 32 pub trait Sealed {} 33 } 34 /// State trait tracking which required fields have been set 35 pub trait State: sealed::Sealed { 36 type Notebook; 37 } 38 /// Empty state - all required fields are unset 39 pub struct Empty(()); 40 impl sealed::Sealed for Empty {} 41 impl State for Empty { 42 type Notebook = Unset; 43 } 44 ///State transition - sets the `notebook` field to Set 45 pub struct SetNotebook<S: State = Empty>(PhantomData<fn() -> S>); 46 impl<S: State> sealed::Sealed for SetNotebook<S> {} 47 impl<S: State> State for SetNotebook<S> { 48 type Notebook = Set<members::notebook>; 49 } 50 /// Marker types for field names 51 #[allow(non_camel_case_types)] 52 pub mod members { 53 ///Marker type for the `notebook` field 54 pub struct notebook(()); 55 } 56} 57 58/// Builder for constructing an instance of this type 59pub struct GetBookEntryBuilder<'a, S: get_book_entry_state::State> { 60 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 61 __unsafe_private_named: ( 62 ::core::option::Option<i64>, 63 ::core::option::Option<jacquard_common::types::string::AtUri<'a>>, 64 ), 65 _phantom: ::core::marker::PhantomData<&'a ()>, 66} 67 68impl<'a> GetBookEntry<'a> { 69 /// Create a new builder for this type 70 pub fn new() -> GetBookEntryBuilder<'a, get_book_entry_state::Empty> { 71 GetBookEntryBuilder::new() 72 } 73} 74 75impl<'a> GetBookEntryBuilder<'a, get_book_entry_state::Empty> { 76 /// Create a new builder with all fields unset 77 pub fn new() -> Self { 78 GetBookEntryBuilder { 79 _phantom_state: ::core::marker::PhantomData, 80 __unsafe_private_named: (None, None), 81 _phantom: ::core::marker::PhantomData, 82 } 83 } 84} 85 86impl<'a, S: get_book_entry_state::State> GetBookEntryBuilder<'a, S> { 87 /// Set the `index` field (optional) 88 pub fn index(mut self, value: impl Into<Option<i64>>) -> Self { 89 self.__unsafe_private_named.0 = value.into(); 90 self 91 } 92 /// Set the `index` field to an Option value (optional) 93 pub fn maybe_index(mut self, value: Option<i64>) -> Self { 94 self.__unsafe_private_named.0 = value; 95 self 96 } 97} 98 99impl<'a, S> GetBookEntryBuilder<'a, S> 100where 101 S: get_book_entry_state::State, 102 S::Notebook: get_book_entry_state::IsUnset, 103{ 104 /// Set the `notebook` field (required) 105 pub fn notebook( 106 mut self, 107 value: impl Into<jacquard_common::types::string::AtUri<'a>>, 108 ) -> GetBookEntryBuilder<'a, get_book_entry_state::SetNotebook<S>> { 109 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); 110 GetBookEntryBuilder { 111 _phantom_state: ::core::marker::PhantomData, 112 __unsafe_private_named: self.__unsafe_private_named, 113 _phantom: ::core::marker::PhantomData, 114 } 115 } 116} 117 118impl<'a, S> GetBookEntryBuilder<'a, S> 119where 120 S: get_book_entry_state::State, 121 S::Notebook: get_book_entry_state::IsSet, 122{ 123 /// Build the final struct 124 pub fn build(self) -> GetBookEntry<'a> { 125 GetBookEntry { 126 index: self.__unsafe_private_named.0, 127 notebook: self.__unsafe_private_named.1.unwrap(), 128 } 129 } 130} 131 132#[jacquard_derive::lexicon] 133#[derive( 134 serde::Serialize, 135 serde::Deserialize, 136 Debug, 137 Clone, 138 PartialEq, 139 Eq, 140 jacquard_derive::IntoStatic 141)] 142#[serde(rename_all = "camelCase")] 143pub struct GetBookEntryOutput<'a> { 144 #[serde(flatten)] 145 #[serde(borrow)] 146 pub value: crate::sh_weaver::notebook::BookEntryView<'a>, 147} 148 149#[jacquard_derive::open_union] 150#[derive( 151 serde::Serialize, 152 serde::Deserialize, 153 Debug, 154 Clone, 155 PartialEq, 156 Eq, 157 thiserror::Error, 158 miette::Diagnostic, 159 jacquard_derive::IntoStatic 160)] 161#[serde(tag = "error", content = "message")] 162#[serde(bound(deserialize = "'de: 'a"))] 163pub enum GetBookEntryError<'a> { 164 #[serde(rename = "NotebookNotFound")] 165 NotebookNotFound(std::option::Option<jacquard_common::CowStr<'a>>), 166 #[serde(rename = "EntryNotFound")] 167 EntryNotFound(std::option::Option<jacquard_common::CowStr<'a>>), 168} 169 170impl core::fmt::Display for GetBookEntryError<'_> { 171 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 172 match self { 173 Self::NotebookNotFound(msg) => { 174 write!(f, "NotebookNotFound")?; 175 if let Some(msg) = msg { 176 write!(f, ": {}", msg)?; 177 } 178 Ok(()) 179 } 180 Self::EntryNotFound(msg) => { 181 write!(f, "EntryNotFound")?; 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///sh.weaver.notebook.getBookEntry 194pub struct GetBookEntryResponse; 195impl jacquard_common::xrpc::XrpcResp for GetBookEntryResponse { 196 const NSID: &'static str = "sh.weaver.notebook.getBookEntry"; 197 const ENCODING: &'static str = "application/json"; 198 type Output<'de> = GetBookEntryOutput<'de>; 199 type Err<'de> = GetBookEntryError<'de>; 200} 201 202impl<'a> jacquard_common::xrpc::XrpcRequest for GetBookEntry<'a> { 203 const NSID: &'static str = "sh.weaver.notebook.getBookEntry"; 204 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; 205 type Response = GetBookEntryResponse; 206} 207 208/// Endpoint type for 209///sh.weaver.notebook.getBookEntry 210pub struct GetBookEntryRequest; 211impl jacquard_common::xrpc::XrpcEndpoint for GetBookEntryRequest { 212 const PATH: &'static str = "/xrpc/sh.weaver.notebook.getBookEntry"; 213 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; 214 type Request<'de> = GetBookEntry<'de>; 215 type Response = GetBookEntryResponse; 216}