jacquard_api/com_atproto/temp/
dereference_scope.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.atproto.temp.dereferenceScope
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 DereferenceScope<'a> {
19    #[serde(borrow)]
20    pub scope: jacquard_common::CowStr<'a>,
21}
22
23pub mod dereference_scope_state {
24
25    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
26    #[allow(unused)]
27    use ::core::marker::PhantomData;
28    mod sealed {
29        pub trait Sealed {}
30    }
31    /// State trait tracking which required fields have been set
32    pub trait State: sealed::Sealed {
33        type Scope;
34    }
35    /// Empty state - all required fields are unset
36    pub struct Empty(());
37    impl sealed::Sealed for Empty {}
38    impl State for Empty {
39        type Scope = Unset;
40    }
41    ///State transition - sets the `scope` field to Set
42    pub struct SetScope<S: State = Empty>(PhantomData<fn() -> S>);
43    impl<S: State> sealed::Sealed for SetScope<S> {}
44    impl<S: State> State for SetScope<S> {
45        type Scope = Set<members::scope>;
46    }
47    /// Marker types for field names
48    #[allow(non_camel_case_types)]
49    pub mod members {
50        ///Marker type for the `scope` field
51        pub struct scope(());
52    }
53}
54
55/// Builder for constructing an instance of this type
56pub struct DereferenceScopeBuilder<'a, S: dereference_scope_state::State> {
57    _phantom_state: ::core::marker::PhantomData<fn() -> S>,
58    __unsafe_private_named: (::core::option::Option<jacquard_common::CowStr<'a>>,),
59    _phantom: ::core::marker::PhantomData<&'a ()>,
60}
61
62impl<'a> DereferenceScope<'a> {
63    /// Create a new builder for this type
64    pub fn new() -> DereferenceScopeBuilder<'a, dereference_scope_state::Empty> {
65        DereferenceScopeBuilder::new()
66    }
67}
68
69impl<'a> DereferenceScopeBuilder<'a, dereference_scope_state::Empty> {
70    /// Create a new builder with all fields unset
71    pub fn new() -> Self {
72        DereferenceScopeBuilder {
73            _phantom_state: ::core::marker::PhantomData,
74            __unsafe_private_named: (None,),
75            _phantom: ::core::marker::PhantomData,
76        }
77    }
78}
79
80impl<'a, S> DereferenceScopeBuilder<'a, S>
81where
82    S: dereference_scope_state::State,
83    S::Scope: dereference_scope_state::IsUnset,
84{
85    /// Set the `scope` field (required)
86    pub fn scope(
87        mut self,
88        value: impl Into<jacquard_common::CowStr<'a>>,
89    ) -> DereferenceScopeBuilder<'a, dereference_scope_state::SetScope<S>> {
90        self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
91        DereferenceScopeBuilder {
92            _phantom_state: ::core::marker::PhantomData,
93            __unsafe_private_named: self.__unsafe_private_named,
94            _phantom: ::core::marker::PhantomData,
95        }
96    }
97}
98
99impl<'a, S> DereferenceScopeBuilder<'a, S>
100where
101    S: dereference_scope_state::State,
102    S::Scope: dereference_scope_state::IsSet,
103{
104    /// Build the final struct
105    pub fn build(self) -> DereferenceScope<'a> {
106        DereferenceScope {
107            scope: self.__unsafe_private_named.0.unwrap(),
108        }
109    }
110}
111
112#[jacquard_derive::lexicon]
113#[derive(
114    serde::Serialize,
115    serde::Deserialize,
116    Debug,
117    Clone,
118    PartialEq,
119    Eq,
120    jacquard_derive::IntoStatic,
121    Default
122)]
123#[serde(rename_all = "camelCase")]
124pub struct DereferenceScopeOutput<'a> {
125    /// The full oauth permission scope
126    #[serde(borrow)]
127    pub scope: jacquard_common::CowStr<'a>,
128}
129
130#[jacquard_derive::open_union]
131#[derive(
132    serde::Serialize,
133    serde::Deserialize,
134    Debug,
135    Clone,
136    PartialEq,
137    Eq,
138    thiserror::Error,
139    miette::Diagnostic,
140    jacquard_derive::IntoStatic
141)]
142#[serde(tag = "error", content = "message")]
143#[serde(bound(deserialize = "'de: 'a"))]
144pub enum DereferenceScopeError<'a> {
145    /// An invalid scope reference was provided.
146    #[serde(rename = "InvalidScopeReference")]
147    InvalidScopeReference(std::option::Option<String>),
148}
149
150impl std::fmt::Display for DereferenceScopeError<'_> {
151    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
152        match self {
153            Self::InvalidScopeReference(msg) => {
154                write!(f, "InvalidScopeReference")?;
155                if let Some(msg) = msg {
156                    write!(f, ": {}", msg)?;
157                }
158                Ok(())
159            }
160            Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
161        }
162    }
163}
164
165/// Response type for
166///com.atproto.temp.dereferenceScope
167pub struct DereferenceScopeResponse;
168impl jacquard_common::xrpc::XrpcResp for DereferenceScopeResponse {
169    const NSID: &'static str = "com.atproto.temp.dereferenceScope";
170    const ENCODING: &'static str = "application/json";
171    type Output<'de> = DereferenceScopeOutput<'de>;
172    type Err<'de> = DereferenceScopeError<'de>;
173}
174
175impl<'a> jacquard_common::xrpc::XrpcRequest for DereferenceScope<'a> {
176    const NSID: &'static str = "com.atproto.temp.dereferenceScope";
177    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
178    type Response = DereferenceScopeResponse;
179}
180
181/// Endpoint type for
182///com.atproto.temp.dereferenceScope
183pub struct DereferenceScopeRequest;
184impl jacquard_common::xrpc::XrpcEndpoint for DereferenceScopeRequest {
185    const PATH: &'static str = "/xrpc/com.atproto.temp.dereferenceScope";
186    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
187    type Request<'de> = DereferenceScope<'de>;
188    type Response = DereferenceScopeResponse;
189}