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