Skip to main content

jacquard_api/app_bsky/embed/
get_embed_external_view.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: app.bsky.embed.getEmbedExternalView
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::{BosStr, DefaultStr, FromStaticStr};
14use jacquard_common::deps::smol_str::SmolStr;
15use jacquard_common::types::string::{AtUri, UriValue};
16use jacquard_common::types::value::Data;
17use jacquard_derive::IntoStatic;
18use serde::{Serialize, Deserialize};
19use crate::app_bsky::embed::external::View;
20use crate::com_atproto::repo::strong_ref::StrongRef;
21
22#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
23#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
24pub struct GetEmbedExternalView<S: BosStr = DefaultStr> {
25    pub uris: Vec<AtUri<S>>,
26    pub url: UriValue<S>,
27}
28
29
30#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
31#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
32pub struct GetEmbedExternalViewOutput<S: BosStr = DefaultStr> {
33    #[serde(skip_serializing_if = "Option::is_none")]
34    pub associated_records: Option<Vec<Data<S>>>,
35    ///StrongRefs (URI+CID) of the Atmosphere records that backed this view, suitable for embedding into a post's external.associatedRefs.
36    #[serde(skip_serializing_if = "Option::is_none")]
37    pub associated_refs: Option<Vec<StrongRef<S>>>,
38    ///Hydrated view of the embed. Present only when the resolved records back the requested URL and supply enough information to populate the required `viewExternal` fields. Omitted alongside the rest of the response when no records resolved or validation failed.
39    #[serde(skip_serializing_if = "Option::is_none")]
40    pub view: Option<View<S>>,
41    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
42    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
43}
44
45/** Response marker for the `app.bsky.embed.getEmbedExternalView` query.
46
47Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `GetEmbedExternalViewOutput<S>` for this endpoint.*/
48pub struct GetEmbedExternalViewResponse;
49impl jacquard_common::xrpc::XrpcResp for GetEmbedExternalViewResponse {
50    const NSID: &'static str = "app.bsky.embed.getEmbedExternalView";
51    const ENCODING: &'static str = "application/json";
52    type Output<S: BosStr> = GetEmbedExternalViewOutput<S>;
53    type Err = jacquard_common::xrpc::GenericError;
54}
55
56impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for GetEmbedExternalView<S> {
57    const NSID: &'static str = "app.bsky.embed.getEmbedExternalView";
58    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
59    type Response = GetEmbedExternalViewResponse;
60}
61
62/** Endpoint marker for the `app.bsky.embed.getEmbedExternalView` query.
63
64Path: `/xrpc/app.bsky.embed.getEmbedExternalView`. The request payload type is `GetEmbedExternalView<S>`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
65pub struct GetEmbedExternalViewRequest;
66impl jacquard_common::xrpc::XrpcEndpoint for GetEmbedExternalViewRequest {
67    const PATH: &'static str = "/xrpc/app.bsky.embed.getEmbedExternalView";
68    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
69    type Request<S: BosStr> = GetEmbedExternalView<S>;
70    type Response = GetEmbedExternalViewResponse;
71}
72
73pub mod get_embed_external_view_state {
74
75    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
76    #[allow(unused)]
77    use ::core::marker::PhantomData;
78    mod sealed {
79        pub trait Sealed {}
80    }
81    /// State trait tracking which required fields have been set
82    pub trait State: sealed::Sealed {
83        type Uris;
84        type Url;
85    }
86    /// Empty state - all required fields are unset
87    pub struct Empty(());
88    impl sealed::Sealed for Empty {}
89    impl State for Empty {
90        type Uris = Unset;
91        type Url = Unset;
92    }
93    ///State transition - sets the `uris` field to Set
94    pub struct SetUris<St: State = Empty>(PhantomData<fn() -> St>);
95    impl<St: State> sealed::Sealed for SetUris<St> {}
96    impl<St: State> State for SetUris<St> {
97        type Uris = Set<members::uris>;
98        type Url = St::Url;
99    }
100    ///State transition - sets the `url` field to Set
101    pub struct SetUrl<St: State = Empty>(PhantomData<fn() -> St>);
102    impl<St: State> sealed::Sealed for SetUrl<St> {}
103    impl<St: State> State for SetUrl<St> {
104        type Uris = St::Uris;
105        type Url = Set<members::url>;
106    }
107    /// Marker types for field names
108    #[allow(non_camel_case_types)]
109    pub mod members {
110        ///Marker type for the `uris` field
111        pub struct uris(());
112        ///Marker type for the `url` field
113        pub struct url(());
114    }
115}
116
117/// Builder for constructing an instance of this type.
118pub struct GetEmbedExternalViewBuilder<
119    St: get_embed_external_view_state::State,
120    S: BosStr = DefaultStr,
121> {
122    _state: PhantomData<fn() -> St>,
123    _fields: (Option<Vec<AtUri<S>>>, Option<UriValue<S>>),
124    _type: PhantomData<fn() -> S>,
125}
126
127impl GetEmbedExternalView<DefaultStr> {
128    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
129    pub fn new() -> GetEmbedExternalViewBuilder<
130        get_embed_external_view_state::Empty,
131        DefaultStr,
132    > {
133        GetEmbedExternalViewBuilder::new()
134    }
135}
136
137impl<S: BosStr> GetEmbedExternalView<S> {
138    /// Create a new builder for this type
139    pub fn builder() -> GetEmbedExternalViewBuilder<
140        get_embed_external_view_state::Empty,
141        S,
142    > {
143        GetEmbedExternalViewBuilder::builder()
144    }
145}
146
147impl GetEmbedExternalViewBuilder<get_embed_external_view_state::Empty, DefaultStr> {
148    /// Create a new builder with all fields unset, using the default string type, if needed
149    pub fn new() -> Self {
150        GetEmbedExternalViewBuilder {
151            _state: PhantomData,
152            _fields: (None, None),
153            _type: PhantomData,
154        }
155    }
156}
157
158impl<S: BosStr> GetEmbedExternalViewBuilder<get_embed_external_view_state::Empty, S> {
159    /// Create a new builder with all fields unset
160    pub fn builder() -> Self {
161        GetEmbedExternalViewBuilder {
162            _state: PhantomData,
163            _fields: (None, None),
164            _type: PhantomData,
165        }
166    }
167}
168
169impl<St, S: BosStr> GetEmbedExternalViewBuilder<St, S>
170where
171    St: get_embed_external_view_state::State,
172    St::Uris: get_embed_external_view_state::IsUnset,
173{
174    /// Set the `uris` field (required)
175    pub fn uris(
176        mut self,
177        value: impl Into<Vec<AtUri<S>>>,
178    ) -> GetEmbedExternalViewBuilder<get_embed_external_view_state::SetUris<St>, S> {
179        self._fields.0 = Option::Some(value.into());
180        GetEmbedExternalViewBuilder {
181            _state: PhantomData,
182            _fields: self._fields,
183            _type: PhantomData,
184        }
185    }
186}
187
188impl<St, S: BosStr> GetEmbedExternalViewBuilder<St, S>
189where
190    St: get_embed_external_view_state::State,
191    St::Url: get_embed_external_view_state::IsUnset,
192{
193    /// Set the `url` field (required)
194    pub fn url(
195        mut self,
196        value: impl Into<UriValue<S>>,
197    ) -> GetEmbedExternalViewBuilder<get_embed_external_view_state::SetUrl<St>, S> {
198        self._fields.1 = Option::Some(value.into());
199        GetEmbedExternalViewBuilder {
200            _state: PhantomData,
201            _fields: self._fields,
202            _type: PhantomData,
203        }
204    }
205}
206
207impl<St, S: BosStr> GetEmbedExternalViewBuilder<St, S>
208where
209    St: get_embed_external_view_state::State,
210    St::Uris: get_embed_external_view_state::IsSet,
211    St::Url: get_embed_external_view_state::IsSet,
212{
213    /// Build the final struct.
214    pub fn build(self) -> GetEmbedExternalView<S> {
215        GetEmbedExternalView {
216            uris: self._fields.0.unwrap(),
217            url: self._fields.1.unwrap(),
218        }
219    }
220}