Something went wrong. Try again.
atproto made easy crates.io/crates/jacquard
atproto rust
Something went wrong. Try again.
5.6 kB · 169 lines
Rust
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169// @generated by jacquard-lexicon. DO NOT EDIT.//// Lexicon: place.stream.live.subscribeSegments//// This file was automatically generated from Lexicon schemas.// Any manual changes will be overwritten on the next regeneration.
#[allow(unused_imports)]use core::marker::PhantomData;use jacquard_common::CowStr;use jacquard_common::deps::bytes::Bytes;use jacquard_derive::{IntoStatic, open_union};use serde::{Serialize, Deserialize};use crate::place_stream::live::subscribe_segments;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]#[serde(rename_all = "camelCase")]pub struct SubscribeSegments<'a> { #[serde(borrow)] pub streamer: CowStr<'a>,}
#[open_union]#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]#[serde(tag = "$type")]#[serde(bound(deserialize = "'de: 'a"))]pub enum SubscribeSegmentsMessage<'a> { #[serde(rename = "#segment")] Segment(Box<subscribe_segments::Segment>),}
impl<'a> SubscribeSegmentsMessage<'a> { /// Decode a framed DAG-CBOR message (header + body). pub fn decode_framed<'de: 'a>( bytes: &'de [u8], ) -> Result<SubscribeSegmentsMessage<'a>, jacquard_common::error::DecodeError> { let (header, body) = jacquard_common::xrpc::subscription::parse_event_header( bytes, )?; match header.t.as_str() { "#segment" => { let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice( body, )?; Ok(Self::Segment(Box::new(variant))) } unknown => { Err( jacquard_common::error::DecodeError::UnknownEventType(unknown.into()), ) } } }}
pub type Segment = Bytes;///Stream response type for///place.stream.live.subscribeSegmentspub struct SubscribeSegmentsStream;impl jacquard_common::xrpc::SubscriptionResp for SubscribeSegmentsStream { const NSID: &'static str = "place.stream.live.subscribeSegments"; const ENCODING: jacquard_common::xrpc::MessageEncoding = jacquard_common::xrpc::MessageEncoding::Json; type Message<'de> = SubscribeSegmentsMessage<'de>; type Error<'de> = jacquard_common::xrpc::GenericError<'de>;}
impl<'a> jacquard_common::xrpc::XrpcSubscription for SubscribeSegments<'a> { const NSID: &'static str = "place.stream.live.subscribeSegments"; const ENCODING: jacquard_common::xrpc::MessageEncoding = jacquard_common::xrpc::MessageEncoding::Json; type Stream = SubscribeSegmentsStream;}
pub struct SubscribeSegmentsEndpoint;impl jacquard_common::xrpc::SubscriptionEndpoint for SubscribeSegmentsEndpoint { const PATH: &'static str = "/xrpc/place.stream.live.subscribeSegments"; const ENCODING: jacquard_common::xrpc::MessageEncoding = jacquard_common::xrpc::MessageEncoding::Json; type Params<'de> = SubscribeSegments<'de>; type Stream = SubscribeSegmentsStream;}
pub mod subscribe_segments_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Streamer; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Streamer = Unset; } ///State transition - sets the `streamer` field to Set pub struct SetStreamer<S: State = Empty>(PhantomData<fn() -> S>); impl<S: State> sealed::Sealed for SetStreamer<S> {} impl<S: State> State for SetStreamer<S> { type Streamer = Set<members::streamer>; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `streamer` field pub struct streamer(()); }}
/// Builder for constructing an instance of this typepub struct SubscribeSegmentsBuilder<'a, S: subscribe_segments_state::State> { _state: PhantomData<fn() -> S>, _fields: (Option<CowStr<'a>>,), _lifetime: PhantomData<&'a ()>,}
impl<'a> SubscribeSegments<'a> { /// Create a new builder for this type pub fn new() -> SubscribeSegmentsBuilder<'a, subscribe_segments_state::Empty> { SubscribeSegmentsBuilder::new() }}
impl<'a> SubscribeSegmentsBuilder<'a, subscribe_segments_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { SubscribeSegmentsBuilder { _state: PhantomData, _fields: (None,), _lifetime: PhantomData, } }}
impl<'a, S> SubscribeSegmentsBuilder<'a, S>where S: subscribe_segments_state::State, S::Streamer: subscribe_segments_state::IsUnset,{ /// Set the `streamer` field (required) pub fn streamer( mut self, value: impl Into<CowStr<'a>>, ) -> SubscribeSegmentsBuilder<'a, subscribe_segments_state::SetStreamer<S>> { self._fields.0 = Option::Some(value.into()); SubscribeSegmentsBuilder { _state: PhantomData, _fields: self._fields, _lifetime: PhantomData, } }}
impl<'a, S> SubscribeSegmentsBuilder<'a, S>where S: subscribe_segments_state::State, S::Streamer: subscribe_segments_state::IsSet,{ /// Build the final struct pub fn build(self) -> SubscribeSegments<'a> { SubscribeSegments { streamer: self._fields.0.unwrap(), } }}