atproto blogging
at main 279 lines 9.0 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: sh.weaver.notebook.resolveEntry 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 ResolveEntry<'a> { 19 #[serde(borrow)] 20 pub actor: jacquard_common::types::ident::AtIdentifier<'a>, 21 #[serde(borrow)] 22 pub entry: jacquard_common::CowStr<'a>, 23 #[serde(borrow)] 24 pub notebook: jacquard_common::CowStr<'a>, 25} 26 27pub mod resolve_entry_state { 28 29 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 30 #[allow(unused)] 31 use ::core::marker::PhantomData; 32 mod sealed { 33 pub trait Sealed {} 34 } 35 /// State trait tracking which required fields have been set 36 pub trait State: sealed::Sealed { 37 type Actor; 38 type Notebook; 39 type Entry; 40 } 41 /// Empty state - all required fields are unset 42 pub struct Empty(()); 43 impl sealed::Sealed for Empty {} 44 impl State for Empty { 45 type Actor = Unset; 46 type Notebook = Unset; 47 type Entry = Unset; 48 } 49 ///State transition - sets the `actor` field to Set 50 pub struct SetActor<S: State = Empty>(PhantomData<fn() -> S>); 51 impl<S: State> sealed::Sealed for SetActor<S> {} 52 impl<S: State> State for SetActor<S> { 53 type Actor = Set<members::actor>; 54 type Notebook = S::Notebook; 55 type Entry = S::Entry; 56 } 57 ///State transition - sets the `notebook` field to Set 58 pub struct SetNotebook<S: State = Empty>(PhantomData<fn() -> S>); 59 impl<S: State> sealed::Sealed for SetNotebook<S> {} 60 impl<S: State> State for SetNotebook<S> { 61 type Actor = S::Actor; 62 type Notebook = Set<members::notebook>; 63 type Entry = S::Entry; 64 } 65 ///State transition - sets the `entry` field to Set 66 pub struct SetEntry<S: State = Empty>(PhantomData<fn() -> S>); 67 impl<S: State> sealed::Sealed for SetEntry<S> {} 68 impl<S: State> State for SetEntry<S> { 69 type Actor = S::Actor; 70 type Notebook = S::Notebook; 71 type Entry = Set<members::entry>; 72 } 73 /// Marker types for field names 74 #[allow(non_camel_case_types)] 75 pub mod members { 76 ///Marker type for the `actor` field 77 pub struct actor(()); 78 ///Marker type for the `notebook` field 79 pub struct notebook(()); 80 ///Marker type for the `entry` field 81 pub struct entry(()); 82 } 83} 84 85/// Builder for constructing an instance of this type 86pub struct ResolveEntryBuilder<'a, S: resolve_entry_state::State> { 87 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 88 __unsafe_private_named: ( 89 ::core::option::Option<jacquard_common::types::ident::AtIdentifier<'a>>, 90 ::core::option::Option<jacquard_common::CowStr<'a>>, 91 ::core::option::Option<jacquard_common::CowStr<'a>>, 92 ), 93 _phantom: ::core::marker::PhantomData<&'a ()>, 94} 95 96impl<'a> ResolveEntry<'a> { 97 /// Create a new builder for this type 98 pub fn new() -> ResolveEntryBuilder<'a, resolve_entry_state::Empty> { 99 ResolveEntryBuilder::new() 100 } 101} 102 103impl<'a> ResolveEntryBuilder<'a, resolve_entry_state::Empty> { 104 /// Create a new builder with all fields unset 105 pub fn new() -> Self { 106 ResolveEntryBuilder { 107 _phantom_state: ::core::marker::PhantomData, 108 __unsafe_private_named: (None, None, None), 109 _phantom: ::core::marker::PhantomData, 110 } 111 } 112} 113 114impl<'a, S> ResolveEntryBuilder<'a, S> 115where 116 S: resolve_entry_state::State, 117 S::Actor: resolve_entry_state::IsUnset, 118{ 119 /// Set the `actor` field (required) 120 pub fn actor( 121 mut self, 122 value: impl Into<jacquard_common::types::ident::AtIdentifier<'a>>, 123 ) -> ResolveEntryBuilder<'a, resolve_entry_state::SetActor<S>> { 124 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 125 ResolveEntryBuilder { 126 _phantom_state: ::core::marker::PhantomData, 127 __unsafe_private_named: self.__unsafe_private_named, 128 _phantom: ::core::marker::PhantomData, 129 } 130 } 131} 132 133impl<'a, S> ResolveEntryBuilder<'a, S> 134where 135 S: resolve_entry_state::State, 136 S::Entry: resolve_entry_state::IsUnset, 137{ 138 /// Set the `entry` field (required) 139 pub fn entry( 140 mut self, 141 value: impl Into<jacquard_common::CowStr<'a>>, 142 ) -> ResolveEntryBuilder<'a, resolve_entry_state::SetEntry<S>> { 143 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); 144 ResolveEntryBuilder { 145 _phantom_state: ::core::marker::PhantomData, 146 __unsafe_private_named: self.__unsafe_private_named, 147 _phantom: ::core::marker::PhantomData, 148 } 149 } 150} 151 152impl<'a, S> ResolveEntryBuilder<'a, S> 153where 154 S: resolve_entry_state::State, 155 S::Notebook: resolve_entry_state::IsUnset, 156{ 157 /// Set the `notebook` field (required) 158 pub fn notebook( 159 mut self, 160 value: impl Into<jacquard_common::CowStr<'a>>, 161 ) -> ResolveEntryBuilder<'a, resolve_entry_state::SetNotebook<S>> { 162 self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into()); 163 ResolveEntryBuilder { 164 _phantom_state: ::core::marker::PhantomData, 165 __unsafe_private_named: self.__unsafe_private_named, 166 _phantom: ::core::marker::PhantomData, 167 } 168 } 169} 170 171impl<'a, S> ResolveEntryBuilder<'a, S> 172where 173 S: resolve_entry_state::State, 174 S::Actor: resolve_entry_state::IsSet, 175 S::Notebook: resolve_entry_state::IsSet, 176 S::Entry: resolve_entry_state::IsSet, 177{ 178 /// Build the final struct 179 pub fn build(self) -> ResolveEntry<'a> { 180 ResolveEntry { 181 actor: self.__unsafe_private_named.0.unwrap(), 182 entry: self.__unsafe_private_named.1.unwrap(), 183 notebook: self.__unsafe_private_named.2.unwrap(), 184 } 185 } 186} 187 188#[jacquard_derive::lexicon] 189#[derive( 190 serde::Serialize, 191 serde::Deserialize, 192 Debug, 193 Clone, 194 PartialEq, 195 Eq, 196 jacquard_derive::IntoStatic 197)] 198#[serde(rename_all = "camelCase")] 199pub struct ResolveEntryOutput<'a> { 200 #[serde(borrow)] 201 pub entry: crate::sh_weaver::notebook::EntryView<'a>, 202 pub notebook_count: i64, 203 #[serde(skip_serializing_if = "std::option::Option::is_none")] 204 #[serde(borrow)] 205 pub notebooks: std::option::Option< 206 Vec<crate::sh_weaver::notebook::NotebookView<'a>>, 207 >, 208 #[serde(borrow)] 209 pub record: jacquard_common::types::value::Data<'a>, 210} 211 212#[jacquard_derive::open_union] 213#[derive( 214 serde::Serialize, 215 serde::Deserialize, 216 Debug, 217 Clone, 218 PartialEq, 219 Eq, 220 thiserror::Error, 221 miette::Diagnostic, 222 jacquard_derive::IntoStatic 223)] 224#[serde(tag = "error", content = "message")] 225#[serde(bound(deserialize = "'de: 'a"))] 226pub enum ResolveEntryError<'a> { 227 #[serde(rename = "NotebookNotFound")] 228 NotebookNotFound(std::option::Option<jacquard_common::CowStr<'a>>), 229 #[serde(rename = "EntryNotFound")] 230 EntryNotFound(std::option::Option<jacquard_common::CowStr<'a>>), 231} 232 233impl core::fmt::Display for ResolveEntryError<'_> { 234 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 235 match self { 236 Self::NotebookNotFound(msg) => { 237 write!(f, "NotebookNotFound")?; 238 if let Some(msg) = msg { 239 write!(f, ": {}", msg)?; 240 } 241 Ok(()) 242 } 243 Self::EntryNotFound(msg) => { 244 write!(f, "EntryNotFound")?; 245 if let Some(msg) = msg { 246 write!(f, ": {}", msg)?; 247 } 248 Ok(()) 249 } 250 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), 251 } 252 } 253} 254 255/// Response type for 256///sh.weaver.notebook.resolveEntry 257pub struct ResolveEntryResponse; 258impl jacquard_common::xrpc::XrpcResp for ResolveEntryResponse { 259 const NSID: &'static str = "sh.weaver.notebook.resolveEntry"; 260 const ENCODING: &'static str = "application/json"; 261 type Output<'de> = ResolveEntryOutput<'de>; 262 type Err<'de> = ResolveEntryError<'de>; 263} 264 265impl<'a> jacquard_common::xrpc::XrpcRequest for ResolveEntry<'a> { 266 const NSID: &'static str = "sh.weaver.notebook.resolveEntry"; 267 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; 268 type Response = ResolveEntryResponse; 269} 270 271/// Endpoint type for 272///sh.weaver.notebook.resolveEntry 273pub struct ResolveEntryRequest; 274impl jacquard_common::xrpc::XrpcEndpoint for ResolveEntryRequest { 275 const PATH: &'static str = "/xrpc/sh.weaver.notebook.resolveEntry"; 276 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; 277 type Request<'de> = ResolveEntry<'de>; 278 type Response = ResolveEntryResponse; 279}