jacquard_api/com_atproto/sync/
get_checkout.rs1#[allow(unused_imports)]
9use core::marker::PhantomData;
10use jacquard_common::deps::bytes::Bytes;
11use jacquard_common::types::string::Did;
12use jacquard_derive::IntoStatic;
13use serde::{Serialize, Deserialize};
14
15#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
16#[serde(rename_all = "camelCase")]
17pub struct GetCheckout<'a> {
18 #[serde(borrow)]
19 pub did: Did<'a>,
20}
21
22
23#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
24#[serde(rename_all = "camelCase")]
25pub struct GetCheckoutOutput {
26 pub body: Bytes,
27}
28
29pub struct GetCheckoutResponse;
31impl jacquard_common::xrpc::XrpcResp for GetCheckoutResponse {
32 const NSID: &'static str = "com.atproto.sync.getCheckout";
33 const ENCODING: &'static str = "application/vnd.ipld.car";
34 type Output<'de> = GetCheckoutOutput;
35 type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
36 fn encode_output(
37 output: &Self::Output<'_>,
38 ) -> Result<Vec<u8>, jacquard_common::xrpc::EncodeError> {
39 Ok(output.body.to_vec())
40 }
41 fn decode_output<'de>(
42 body: &'de [u8],
43 ) -> Result<Self::Output<'de>, jacquard_common::error::DecodeError>
44 where
45 Self::Output<'de>: serde::Deserialize<'de>,
46 {
47 Ok(GetCheckoutOutput {
48 body: jacquard_common::deps::bytes::Bytes::copy_from_slice(body),
49 })
50 }
51}
52
53impl<'a> jacquard_common::xrpc::XrpcRequest for GetCheckout<'a> {
54 const NSID: &'static str = "com.atproto.sync.getCheckout";
55 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
56 type Response = GetCheckoutResponse;
57}
58
59pub struct GetCheckoutRequest;
61impl jacquard_common::xrpc::XrpcEndpoint for GetCheckoutRequest {
62 const PATH: &'static str = "/xrpc/com.atproto.sync.getCheckout";
63 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
64 type Request<'de> = GetCheckout<'de>;
65 type Response = GetCheckoutResponse;
66}
67
68pub mod get_checkout_state {
69
70 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
71 #[allow(unused)]
72 use ::core::marker::PhantomData;
73 mod sealed {
74 pub trait Sealed {}
75 }
76 pub trait State: sealed::Sealed {
78 type Did;
79 }
80 pub struct Empty(());
82 impl sealed::Sealed for Empty {}
83 impl State for Empty {
84 type Did = Unset;
85 }
86 pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>);
88 impl<S: State> sealed::Sealed for SetDid<S> {}
89 impl<S: State> State for SetDid<S> {
90 type Did = Set<members::did>;
91 }
92 #[allow(non_camel_case_types)]
94 pub mod members {
95 pub struct did(());
97 }
98}
99
100pub struct GetCheckoutBuilder<'a, S: get_checkout_state::State> {
102 _state: PhantomData<fn() -> S>,
103 _fields: (Option<Did<'a>>,),
104 _lifetime: PhantomData<&'a ()>,
105}
106
107impl<'a> GetCheckout<'a> {
108 pub fn new() -> GetCheckoutBuilder<'a, get_checkout_state::Empty> {
110 GetCheckoutBuilder::new()
111 }
112}
113
114impl<'a> GetCheckoutBuilder<'a, get_checkout_state::Empty> {
115 pub fn new() -> Self {
117 GetCheckoutBuilder {
118 _state: PhantomData,
119 _fields: (None,),
120 _lifetime: PhantomData,
121 }
122 }
123}
124
125impl<'a, S> GetCheckoutBuilder<'a, S>
126where
127 S: get_checkout_state::State,
128 S::Did: get_checkout_state::IsUnset,
129{
130 pub fn did(
132 mut self,
133 value: impl Into<Did<'a>>,
134 ) -> GetCheckoutBuilder<'a, get_checkout_state::SetDid<S>> {
135 self._fields.0 = Option::Some(value.into());
136 GetCheckoutBuilder {
137 _state: PhantomData,
138 _fields: self._fields,
139 _lifetime: PhantomData,
140 }
141 }
142}
143
144impl<'a, S> GetCheckoutBuilder<'a, S>
145where
146 S: get_checkout_state::State,
147 S::Did: get_checkout_state::IsSet,
148{
149 pub fn build(self) -> GetCheckout<'a> {
151 GetCheckout {
152 did: self._fields.0.unwrap(),
153 }
154 }
155}