atproto blogging
1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: app.bsky.graph.getRelationships
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 GetRelationships<'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 others: std::option::Option<
24 Vec<jacquard_common::types::ident::AtIdentifier<'a>>,
25 >,
26}
27
28pub mod get_relationships_state {
29
30 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
31 #[allow(unused)]
32 use ::core::marker::PhantomData;
33 mod sealed {
34 pub trait Sealed {}
35 }
36 /// State trait tracking which required fields have been set
37 pub trait State: sealed::Sealed {
38 type Actor;
39 }
40 /// Empty state - all required fields are unset
41 pub struct Empty(());
42 impl sealed::Sealed for Empty {}
43 impl State for Empty {
44 type Actor = Unset;
45 }
46 ///State transition - sets the `actor` field to Set
47 pub struct SetActor<S: State = Empty>(PhantomData<fn() -> S>);
48 impl<S: State> sealed::Sealed for SetActor<S> {}
49 impl<S: State> State for SetActor<S> {
50 type Actor = Set<members::actor>;
51 }
52 /// Marker types for field names
53 #[allow(non_camel_case_types)]
54 pub mod members {
55 ///Marker type for the `actor` field
56 pub struct actor(());
57 }
58}
59
60/// Builder for constructing an instance of this type
61pub struct GetRelationshipsBuilder<'a, S: get_relationships_state::State> {
62 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
63 __unsafe_private_named: (
64 ::core::option::Option<jacquard_common::types::ident::AtIdentifier<'a>>,
65 ::core::option::Option<Vec<jacquard_common::types::ident::AtIdentifier<'a>>>,
66 ),
67 _phantom: ::core::marker::PhantomData<&'a ()>,
68}
69
70impl<'a> GetRelationships<'a> {
71 /// Create a new builder for this type
72 pub fn new() -> GetRelationshipsBuilder<'a, get_relationships_state::Empty> {
73 GetRelationshipsBuilder::new()
74 }
75}
76
77impl<'a> GetRelationshipsBuilder<'a, get_relationships_state::Empty> {
78 /// Create a new builder with all fields unset
79 pub fn new() -> Self {
80 GetRelationshipsBuilder {
81 _phantom_state: ::core::marker::PhantomData,
82 __unsafe_private_named: (None, None),
83 _phantom: ::core::marker::PhantomData,
84 }
85 }
86}
87
88impl<'a, S> GetRelationshipsBuilder<'a, S>
89where
90 S: get_relationships_state::State,
91 S::Actor: get_relationships_state::IsUnset,
92{
93 /// Set the `actor` field (required)
94 pub fn actor(
95 mut self,
96 value: impl Into<jacquard_common::types::ident::AtIdentifier<'a>>,
97 ) -> GetRelationshipsBuilder<'a, get_relationships_state::SetActor<S>> {
98 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
99 GetRelationshipsBuilder {
100 _phantom_state: ::core::marker::PhantomData,
101 __unsafe_private_named: self.__unsafe_private_named,
102 _phantom: ::core::marker::PhantomData,
103 }
104 }
105}
106
107impl<'a, S: get_relationships_state::State> GetRelationshipsBuilder<'a, S> {
108 /// Set the `others` field (optional)
109 pub fn others(
110 mut self,
111 value: impl Into<Option<Vec<jacquard_common::types::ident::AtIdentifier<'a>>>>,
112 ) -> Self {
113 self.__unsafe_private_named.1 = value.into();
114 self
115 }
116 /// Set the `others` field to an Option value (optional)
117 pub fn maybe_others(
118 mut self,
119 value: Option<Vec<jacquard_common::types::ident::AtIdentifier<'a>>>,
120 ) -> Self {
121 self.__unsafe_private_named.1 = value;
122 self
123 }
124}
125
126impl<'a, S> GetRelationshipsBuilder<'a, S>
127where
128 S: get_relationships_state::State,
129 S::Actor: get_relationships_state::IsSet,
130{
131 /// Build the final struct
132 pub fn build(self) -> GetRelationships<'a> {
133 GetRelationships {
134 actor: self.__unsafe_private_named.0.unwrap(),
135 others: self.__unsafe_private_named.1,
136 }
137 }
138}
139
140#[jacquard_derive::lexicon]
141#[derive(
142 serde::Serialize,
143 serde::Deserialize,
144 Debug,
145 Clone,
146 PartialEq,
147 Eq,
148 jacquard_derive::IntoStatic
149)]
150#[serde(rename_all = "camelCase")]
151pub struct GetRelationshipsOutput<'a> {
152 #[serde(skip_serializing_if = "std::option::Option::is_none")]
153 #[serde(borrow)]
154 pub actor: std::option::Option<jacquard_common::types::string::Did<'a>>,
155 #[serde(borrow)]
156 pub relationships: Vec<GetRelationshipsOutputRelationshipsItem<'a>>,
157}
158
159#[jacquard_derive::open_union]
160#[derive(
161 serde::Serialize,
162 serde::Deserialize,
163 Debug,
164 Clone,
165 PartialEq,
166 Eq,
167 jacquard_derive::IntoStatic
168)]
169#[serde(tag = "$type")]
170#[serde(bound(deserialize = "'de: 'a"))]
171pub enum GetRelationshipsOutputRelationshipsItem<'a> {
172 #[serde(rename = "app.bsky.graph.defs#relationship")]
173 Relationship(Box<crate::app_bsky::graph::Relationship<'a>>),
174 #[serde(rename = "app.bsky.graph.defs#notFoundActor")]
175 NotFoundActor(Box<crate::app_bsky::graph::NotFoundActor<'a>>),
176}
177
178#[jacquard_derive::open_union]
179#[derive(
180 serde::Serialize,
181 serde::Deserialize,
182 Debug,
183 Clone,
184 PartialEq,
185 Eq,
186 thiserror::Error,
187 miette::Diagnostic,
188 jacquard_derive::IntoStatic
189)]
190#[serde(tag = "error", content = "message")]
191#[serde(bound(deserialize = "'de: 'a"))]
192pub enum GetRelationshipsError<'a> {
193 /// the primary actor at-identifier could not be resolved
194 #[serde(rename = "ActorNotFound")]
195 ActorNotFound(std::option::Option<jacquard_common::CowStr<'a>>),
196}
197
198impl core::fmt::Display for GetRelationshipsError<'_> {
199 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
200 match self {
201 Self::ActorNotFound(msg) => {
202 write!(f, "ActorNotFound")?;
203 if let Some(msg) = msg {
204 write!(f, ": {}", msg)?;
205 }
206 Ok(())
207 }
208 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
209 }
210 }
211}
212
213/// Response type for
214///app.bsky.graph.getRelationships
215pub struct GetRelationshipsResponse;
216impl jacquard_common::xrpc::XrpcResp for GetRelationshipsResponse {
217 const NSID: &'static str = "app.bsky.graph.getRelationships";
218 const ENCODING: &'static str = "application/json";
219 type Output<'de> = GetRelationshipsOutput<'de>;
220 type Err<'de> = GetRelationshipsError<'de>;
221}
222
223impl<'a> jacquard_common::xrpc::XrpcRequest for GetRelationships<'a> {
224 const NSID: &'static str = "app.bsky.graph.getRelationships";
225 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
226 type Response = GetRelationshipsResponse;
227}
228
229/// Endpoint type for
230///app.bsky.graph.getRelationships
231pub struct GetRelationshipsRequest;
232impl jacquard_common::xrpc::XrpcEndpoint for GetRelationshipsRequest {
233 const PATH: &'static str = "/xrpc/app.bsky.graph.getRelationships";
234 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
235 type Request<'de> = GetRelationships<'de>;
236 type Response = GetRelationshipsResponse;
237}