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