Skip to main content

jacquard_api/com_atproto/identity/
refresh_identity.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.atproto.identity.refreshIdentity
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::CowStr;
14use jacquard_common::types::ident::AtIdentifier;
15use jacquard_derive::{IntoStatic, lexicon, open_union};
16use serde::{Serialize, Deserialize};
17use crate::com_atproto::identity::IdentityInfo;
18
19#[lexicon]
20#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
21#[serde(rename_all = "camelCase")]
22pub struct RefreshIdentity<'a> {
23    #[serde(borrow)]
24    pub identifier: AtIdentifier<'a>,
25}
26
27
28#[lexicon]
29#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
30#[serde(rename_all = "camelCase")]
31pub struct RefreshIdentityOutput<'a> {
32    #[serde(flatten)]
33    #[serde(borrow)]
34    pub value: IdentityInfo<'a>,
35}
36
37
38#[open_union]
39#[derive(
40    Serialize,
41    Deserialize,
42    Debug,
43    Clone,
44    PartialEq,
45    Eq,
46    thiserror::Error,
47    miette::Diagnostic,
48    IntoStatic
49)]
50
51#[serde(tag = "error", content = "message")]
52#[serde(bound(deserialize = "'de: 'a"))]
53pub enum RefreshIdentityError<'a> {
54    /// The resolution process confirmed that the handle does not resolve to any DID.
55    #[serde(rename = "HandleNotFound")]
56    HandleNotFound(Option<CowStr<'a>>),
57    /// The DID resolution process confirmed that there is no current DID.
58    #[serde(rename = "DidNotFound")]
59    DidNotFound(Option<CowStr<'a>>),
60    /// The DID previously existed, but has been deactivated.
61    #[serde(rename = "DidDeactivated")]
62    DidDeactivated(Option<CowStr<'a>>),
63}
64
65impl core::fmt::Display for RefreshIdentityError<'_> {
66    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
67        match self {
68            Self::HandleNotFound(msg) => {
69                write!(f, "HandleNotFound")?;
70                if let Some(msg) = msg {
71                    write!(f, ": {}", msg)?;
72                }
73                Ok(())
74            }
75            Self::DidNotFound(msg) => {
76                write!(f, "DidNotFound")?;
77                if let Some(msg) = msg {
78                    write!(f, ": {}", msg)?;
79                }
80                Ok(())
81            }
82            Self::DidDeactivated(msg) => {
83                write!(f, "DidDeactivated")?;
84                if let Some(msg) = msg {
85                    write!(f, ": {}", msg)?;
86                }
87                Ok(())
88            }
89            Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
90        }
91    }
92}
93
94/// Response type for com.atproto.identity.refreshIdentity
95pub struct RefreshIdentityResponse;
96impl jacquard_common::xrpc::XrpcResp for RefreshIdentityResponse {
97    const NSID: &'static str = "com.atproto.identity.refreshIdentity";
98    const ENCODING: &'static str = "application/json";
99    type Output<'de> = RefreshIdentityOutput<'de>;
100    type Err<'de> = RefreshIdentityError<'de>;
101}
102
103impl<'a> jacquard_common::xrpc::XrpcRequest for RefreshIdentity<'a> {
104    const NSID: &'static str = "com.atproto.identity.refreshIdentity";
105    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
106        "application/json",
107    );
108    type Response = RefreshIdentityResponse;
109}
110
111/// Endpoint type for com.atproto.identity.refreshIdentity
112pub struct RefreshIdentityRequest;
113impl jacquard_common::xrpc::XrpcEndpoint for RefreshIdentityRequest {
114    const PATH: &'static str = "/xrpc/com.atproto.identity.refreshIdentity";
115    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
116        "application/json",
117    );
118    type Request<'de> = RefreshIdentity<'de>;
119    type Response = RefreshIdentityResponse;
120}
121
122pub mod refresh_identity_state {
123
124    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
125    #[allow(unused)]
126    use ::core::marker::PhantomData;
127    mod sealed {
128        pub trait Sealed {}
129    }
130    /// State trait tracking which required fields have been set
131    pub trait State: sealed::Sealed {
132        type Identifier;
133    }
134    /// Empty state - all required fields are unset
135    pub struct Empty(());
136    impl sealed::Sealed for Empty {}
137    impl State for Empty {
138        type Identifier = Unset;
139    }
140    ///State transition - sets the `identifier` field to Set
141    pub struct SetIdentifier<S: State = Empty>(PhantomData<fn() -> S>);
142    impl<S: State> sealed::Sealed for SetIdentifier<S> {}
143    impl<S: State> State for SetIdentifier<S> {
144        type Identifier = Set<members::identifier>;
145    }
146    /// Marker types for field names
147    #[allow(non_camel_case_types)]
148    pub mod members {
149        ///Marker type for the `identifier` field
150        pub struct identifier(());
151    }
152}
153
154/// Builder for constructing an instance of this type
155pub struct RefreshIdentityBuilder<'a, S: refresh_identity_state::State> {
156    _state: PhantomData<fn() -> S>,
157    _fields: (Option<AtIdentifier<'a>>,),
158    _lifetime: PhantomData<&'a ()>,
159}
160
161impl<'a> RefreshIdentity<'a> {
162    /// Create a new builder for this type
163    pub fn new() -> RefreshIdentityBuilder<'a, refresh_identity_state::Empty> {
164        RefreshIdentityBuilder::new()
165    }
166}
167
168impl<'a> RefreshIdentityBuilder<'a, refresh_identity_state::Empty> {
169    /// Create a new builder with all fields unset
170    pub fn new() -> Self {
171        RefreshIdentityBuilder {
172            _state: PhantomData,
173            _fields: (None,),
174            _lifetime: PhantomData,
175        }
176    }
177}
178
179impl<'a, S> RefreshIdentityBuilder<'a, S>
180where
181    S: refresh_identity_state::State,
182    S::Identifier: refresh_identity_state::IsUnset,
183{
184    /// Set the `identifier` field (required)
185    pub fn identifier(
186        mut self,
187        value: impl Into<AtIdentifier<'a>>,
188    ) -> RefreshIdentityBuilder<'a, refresh_identity_state::SetIdentifier<S>> {
189        self._fields.0 = Option::Some(value.into());
190        RefreshIdentityBuilder {
191            _state: PhantomData,
192            _fields: self._fields,
193            _lifetime: PhantomData,
194        }
195    }
196}
197
198impl<'a, S> RefreshIdentityBuilder<'a, S>
199where
200    S: refresh_identity_state::State,
201    S::Identifier: refresh_identity_state::IsSet,
202{
203    /// Build the final struct
204    pub fn build(self) -> RefreshIdentity<'a> {
205        RefreshIdentity {
206            identifier: self._fields.0.unwrap(),
207            extra_data: Default::default(),
208        }
209    }
210    /// Build the final struct with custom extra_data
211    pub fn build_with_data(
212        self,
213        extra_data: BTreeMap<
214            jacquard_common::deps::smol_str::SmolStr,
215            jacquard_common::types::value::Data<'a>,
216        >,
217    ) -> RefreshIdentity<'a> {
218        RefreshIdentity {
219            identifier: self._fields.0.unwrap(),
220            extra_data: Some(extra_data),
221        }
222    }
223}