Skip to main content

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