Skip to main content

jacquard_api/place_stream/playback/
whep.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: place.stream.playback.whep
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 core::marker::PhantomData;
10use jacquard_common::CowStr;
11use jacquard_common::deps::bytes::Bytes;
12use jacquard_derive::{IntoStatic, open_union};
13use serde::{Serialize, Deserialize};
14
15#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
16#[serde(rename_all = "camelCase")]
17pub struct WhepParams<'a> {
18    #[serde(borrow)]
19    pub rendition: CowStr<'a>,
20    #[serde(borrow)]
21    pub streamer: CowStr<'a>,
22}
23
24
25#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
26#[serde(rename_all = "camelCase")]
27pub struct Whep {
28    pub body: Bytes,
29}
30
31
32#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
33#[serde(rename_all = "camelCase")]
34pub struct WhepOutput {
35    pub body: Bytes,
36}
37
38
39#[open_union]
40#[derive(
41    Serialize,
42    Deserialize,
43    Debug,
44    Clone,
45    PartialEq,
46    Eq,
47    thiserror::Error,
48    miette::Diagnostic,
49    IntoStatic
50)]
51
52#[serde(tag = "error", content = "message")]
53#[serde(bound(deserialize = "'de: 'a"))]
54pub enum WhepError<'a> {
55    /// This user may not play this stream.
56    #[serde(rename = "Unauthorized")]
57    Unauthorized(Option<CowStr<'a>>),
58}
59
60impl core::fmt::Display for WhepError<'_> {
61    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
62        match self {
63            Self::Unauthorized(msg) => {
64                write!(f, "Unauthorized")?;
65                if let Some(msg) = msg {
66                    write!(f, ": {}", msg)?;
67                }
68                Ok(())
69            }
70            Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
71        }
72    }
73}
74
75/// Response type for place.stream.playback.whep
76pub struct WhepResponse;
77impl jacquard_common::xrpc::XrpcResp for WhepResponse {
78    const NSID: &'static str = "place.stream.playback.whep";
79    const ENCODING: &'static str = "*/*";
80    type Output<'de> = WhepOutput;
81    type Err<'de> = WhepError<'de>;
82    fn encode_output(
83        output: &Self::Output<'_>,
84    ) -> Result<Vec<u8>, jacquard_common::xrpc::EncodeError> {
85        Ok(output.body.to_vec())
86    }
87    fn decode_output<'de>(
88        body: &'de [u8],
89    ) -> Result<Self::Output<'de>, jacquard_common::error::DecodeError>
90    where
91        Self::Output<'de>: serde::Deserialize<'de>,
92    {
93        Ok(WhepOutput {
94            body: jacquard_common::deps::bytes::Bytes::copy_from_slice(body),
95        })
96    }
97}
98
99impl jacquard_common::xrpc::XrpcRequest for Whep {
100    const NSID: &'static str = "place.stream.playback.whep";
101    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
102        "*/*",
103    );
104    type Response = WhepResponse;
105    fn encode_body(&self) -> Result<Vec<u8>, jacquard_common::xrpc::EncodeError> {
106        Ok(self.body.to_vec())
107    }
108    fn decode_body<'de>(
109        body: &'de [u8],
110    ) -> Result<Box<Self>, jacquard_common::error::DecodeError>
111    where
112        Self: serde::Deserialize<'de>,
113    {
114        Ok(
115            Box::new(Self {
116                body: jacquard_common::deps::bytes::Bytes::copy_from_slice(body),
117            }),
118        )
119    }
120}
121
122/// Endpoint type for place.stream.playback.whep
123pub struct WhepRequest;
124impl jacquard_common::xrpc::XrpcEndpoint for WhepRequest {
125    const PATH: &'static str = "/xrpc/place.stream.playback.whep";
126    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
127        "*/*",
128    );
129    type Request<'de> = Whep;
130    type Response = WhepResponse;
131}
132
133pub mod whep_params_state {
134
135    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
136    #[allow(unused)]
137    use ::core::marker::PhantomData;
138    mod sealed {
139        pub trait Sealed {}
140    }
141    /// State trait tracking which required fields have been set
142    pub trait State: sealed::Sealed {
143        type Rendition;
144        type Streamer;
145    }
146    /// Empty state - all required fields are unset
147    pub struct Empty(());
148    impl sealed::Sealed for Empty {}
149    impl State for Empty {
150        type Rendition = Unset;
151        type Streamer = Unset;
152    }
153    ///State transition - sets the `rendition` field to Set
154    pub struct SetRendition<S: State = Empty>(PhantomData<fn() -> S>);
155    impl<S: State> sealed::Sealed for SetRendition<S> {}
156    impl<S: State> State for SetRendition<S> {
157        type Rendition = Set<members::rendition>;
158        type Streamer = S::Streamer;
159    }
160    ///State transition - sets the `streamer` field to Set
161    pub struct SetStreamer<S: State = Empty>(PhantomData<fn() -> S>);
162    impl<S: State> sealed::Sealed for SetStreamer<S> {}
163    impl<S: State> State for SetStreamer<S> {
164        type Rendition = S::Rendition;
165        type Streamer = Set<members::streamer>;
166    }
167    /// Marker types for field names
168    #[allow(non_camel_case_types)]
169    pub mod members {
170        ///Marker type for the `rendition` field
171        pub struct rendition(());
172        ///Marker type for the `streamer` field
173        pub struct streamer(());
174    }
175}
176
177/// Builder for constructing an instance of this type
178pub struct WhepParamsBuilder<'a, S: whep_params_state::State> {
179    _state: PhantomData<fn() -> S>,
180    _fields: (Option<CowStr<'a>>, Option<CowStr<'a>>),
181    _lifetime: PhantomData<&'a ()>,
182}
183
184impl<'a> WhepParams<'a> {
185    /// Create a new builder for this type
186    pub fn new() -> WhepParamsBuilder<'a, whep_params_state::Empty> {
187        WhepParamsBuilder::new()
188    }
189}
190
191impl<'a> WhepParamsBuilder<'a, whep_params_state::Empty> {
192    /// Create a new builder with all fields unset
193    pub fn new() -> Self {
194        WhepParamsBuilder {
195            _state: PhantomData,
196            _fields: (None, None),
197            _lifetime: PhantomData,
198        }
199    }
200}
201
202impl<'a, S> WhepParamsBuilder<'a, S>
203where
204    S: whep_params_state::State,
205    S::Rendition: whep_params_state::IsUnset,
206{
207    /// Set the `rendition` field (required)
208    pub fn rendition(
209        mut self,
210        value: impl Into<CowStr<'a>>,
211    ) -> WhepParamsBuilder<'a, whep_params_state::SetRendition<S>> {
212        self._fields.0 = Option::Some(value.into());
213        WhepParamsBuilder {
214            _state: PhantomData,
215            _fields: self._fields,
216            _lifetime: PhantomData,
217        }
218    }
219}
220
221impl<'a, S> WhepParamsBuilder<'a, S>
222where
223    S: whep_params_state::State,
224    S::Streamer: whep_params_state::IsUnset,
225{
226    /// Set the `streamer` field (required)
227    pub fn streamer(
228        mut self,
229        value: impl Into<CowStr<'a>>,
230    ) -> WhepParamsBuilder<'a, whep_params_state::SetStreamer<S>> {
231        self._fields.1 = Option::Some(value.into());
232        WhepParamsBuilder {
233            _state: PhantomData,
234            _fields: self._fields,
235            _lifetime: PhantomData,
236        }
237    }
238}
239
240impl<'a, S> WhepParamsBuilder<'a, S>
241where
242    S: whep_params_state::State,
243    S::Rendition: whep_params_state::IsSet,
244    S::Streamer: whep_params_state::IsSet,
245{
246    /// Build the final struct
247    pub fn build(self) -> WhepParams<'a> {
248        WhepParams {
249            rendition: self._fields.0.unwrap(),
250            streamer: self._fields.1.unwrap(),
251        }
252    }
253}