Skip to main content

jacquard_api/com_whtwnd/blog/
get_author_posts.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.whtwnd.blog.getAuthorPosts
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::types::string::Did;
14use jacquard_derive::{IntoStatic, lexicon};
15use serde::{Serialize, Deserialize};
16use crate::com_whtwnd::blog::BlogEntry;
17
18#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
19#[serde(rename_all = "camelCase")]
20pub struct GetAuthorPosts<'a> {
21    #[serde(borrow)]
22    pub author: Did<'a>,
23}
24
25
26#[lexicon]
27#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
28#[serde(rename_all = "camelCase")]
29pub struct GetAuthorPostsOutput<'a> {
30    #[serde(borrow)]
31    pub post: Vec<BlogEntry<'a>>,
32}
33
34/// Response type for com.whtwnd.blog.getAuthorPosts
35pub struct GetAuthorPostsResponse;
36impl jacquard_common::xrpc::XrpcResp for GetAuthorPostsResponse {
37    const NSID: &'static str = "com.whtwnd.blog.getAuthorPosts";
38    const ENCODING: &'static str = "application/json";
39    type Output<'de> = GetAuthorPostsOutput<'de>;
40    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
41}
42
43impl<'a> jacquard_common::xrpc::XrpcRequest for GetAuthorPosts<'a> {
44    const NSID: &'static str = "com.whtwnd.blog.getAuthorPosts";
45    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
46    type Response = GetAuthorPostsResponse;
47}
48
49/// Endpoint type for com.whtwnd.blog.getAuthorPosts
50pub struct GetAuthorPostsRequest;
51impl jacquard_common::xrpc::XrpcEndpoint for GetAuthorPostsRequest {
52    const PATH: &'static str = "/xrpc/com.whtwnd.blog.getAuthorPosts";
53    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
54    type Request<'de> = GetAuthorPosts<'de>;
55    type Response = GetAuthorPostsResponse;
56}
57
58pub mod get_author_posts_state {
59
60    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
61    #[allow(unused)]
62    use ::core::marker::PhantomData;
63    mod sealed {
64        pub trait Sealed {}
65    }
66    /// State trait tracking which required fields have been set
67    pub trait State: sealed::Sealed {
68        type Author;
69    }
70    /// Empty state - all required fields are unset
71    pub struct Empty(());
72    impl sealed::Sealed for Empty {}
73    impl State for Empty {
74        type Author = Unset;
75    }
76    ///State transition - sets the `author` field to Set
77    pub struct SetAuthor<S: State = Empty>(PhantomData<fn() -> S>);
78    impl<S: State> sealed::Sealed for SetAuthor<S> {}
79    impl<S: State> State for SetAuthor<S> {
80        type Author = Set<members::author>;
81    }
82    /// Marker types for field names
83    #[allow(non_camel_case_types)]
84    pub mod members {
85        ///Marker type for the `author` field
86        pub struct author(());
87    }
88}
89
90/// Builder for constructing an instance of this type
91pub struct GetAuthorPostsBuilder<'a, S: get_author_posts_state::State> {
92    _state: PhantomData<fn() -> S>,
93    _fields: (Option<Did<'a>>,),
94    _lifetime: PhantomData<&'a ()>,
95}
96
97impl<'a> GetAuthorPosts<'a> {
98    /// Create a new builder for this type
99    pub fn new() -> GetAuthorPostsBuilder<'a, get_author_posts_state::Empty> {
100        GetAuthorPostsBuilder::new()
101    }
102}
103
104impl<'a> GetAuthorPostsBuilder<'a, get_author_posts_state::Empty> {
105    /// Create a new builder with all fields unset
106    pub fn new() -> Self {
107        GetAuthorPostsBuilder {
108            _state: PhantomData,
109            _fields: (None,),
110            _lifetime: PhantomData,
111        }
112    }
113}
114
115impl<'a, S> GetAuthorPostsBuilder<'a, S>
116where
117    S: get_author_posts_state::State,
118    S::Author: get_author_posts_state::IsUnset,
119{
120    /// Set the `author` field (required)
121    pub fn author(
122        mut self,
123        value: impl Into<Did<'a>>,
124    ) -> GetAuthorPostsBuilder<'a, get_author_posts_state::SetAuthor<S>> {
125        self._fields.0 = Option::Some(value.into());
126        GetAuthorPostsBuilder {
127            _state: PhantomData,
128            _fields: self._fields,
129            _lifetime: PhantomData,
130        }
131    }
132}
133
134impl<'a, S> GetAuthorPostsBuilder<'a, S>
135where
136    S: get_author_posts_state::State,
137    S::Author: get_author_posts_state::IsSet,
138{
139    /// Build the final struct
140    pub fn build(self) -> GetAuthorPosts<'a> {
141        GetAuthorPosts {
142            author: self._fields.0.unwrap(),
143        }
144    }
145}