jacquard_api/app_bsky/embed/
get_embed_external_view.rs1#[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 #[serde(skip_serializing_if = "Option::is_none")]
37 pub associated_refs: Option<Vec<StrongRef<S>>>,
38 #[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
45pub 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
62pub 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 pub trait State: sealed::Sealed {
83 type Uris;
84 type Url;
85 }
86 pub struct Empty(());
88 impl sealed::Sealed for Empty {}
89 impl State for Empty {
90 type Uris = Unset;
91 type Url = Unset;
92 }
93 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 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 #[allow(non_camel_case_types)]
109 pub mod members {
110 pub struct uris(());
112 pub struct url(());
114 }
115}
116
117pub 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 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 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 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 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 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 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 pub fn build(self) -> GetEmbedExternalView<S> {
215 GetEmbedExternalView {
216 uris: self._fields.0.unwrap(),
217 url: self._fields.1.unwrap(),
218 }
219 }
220}