Skip to main content

jacquard_api/app_bsky/contact/
remove_data.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: app.bsky.contact.removeData
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
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::deps::smol_str::SmolStr;
14use jacquard_common::types::value::Data;
15use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
16use jacquard_derive::{IntoStatic, open_union};
17use serde::{Deserialize, Serialize};
18
19#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
20#[serde(
21    rename_all = "camelCase",
22    bound(deserialize = "S: Deserialize<'de> + BosStr")
23)]
24pub struct RemoveData<S: BosStr = DefaultStr> {
25    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
26    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
27}
28
29#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
30#[serde(
31    rename_all = "camelCase",
32    bound(deserialize = "S: Deserialize<'de> + BosStr")
33)]
34pub struct RemoveDataOutput<S: BosStr = DefaultStr> {
35    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
36    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
37}
38
39#[derive(
40    Serialize, Deserialize, Debug, Clone, PartialEq, Eq, thiserror::Error, miette::Diagnostic,
41)]
42#[serde(tag = "error", content = "message")]
43pub enum RemoveDataError {
44    #[serde(rename = "InvalidDid")]
45    InvalidDid(Option<SmolStr>),
46    #[serde(rename = "InternalError")]
47    InternalError(Option<SmolStr>),
48    /// Catch-all for unknown error codes.
49    #[serde(untagged)]
50    Other {
51        error: SmolStr,
52        message: Option<SmolStr>,
53    },
54}
55
56impl core::fmt::Display for RemoveDataError {
57    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
58        match self {
59            Self::InvalidDid(msg) => {
60                write!(f, "InvalidDid")?;
61                if let Some(msg) = msg {
62                    write!(f, ": {}", msg)?;
63                }
64                Ok(())
65            }
66            Self::InternalError(msg) => {
67                write!(f, "InternalError")?;
68                if let Some(msg) = msg {
69                    write!(f, ": {}", msg)?;
70                }
71                Ok(())
72            }
73            Self::Other { error, message } => {
74                write!(f, "{}", error)?;
75                if let Some(msg) = message {
76                    write!(f, ": {}", msg)?;
77                }
78                Ok(())
79            }
80        }
81    }
82}
83
84/** Response marker for the `app.bsky.contact.removeData` procedure.
85
86Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `RemoveDataOutput<S>` for this endpoint.*/
87pub struct RemoveDataResponse;
88impl jacquard_common::xrpc::XrpcResp for RemoveDataResponse {
89    const NSID: &'static str = "app.bsky.contact.removeData";
90    const ENCODING: &'static str = "application/json";
91    type Output<S: BosStr> = RemoveDataOutput<S>;
92    type Err = RemoveDataError;
93}
94
95impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for RemoveData<S> {
96    const NSID: &'static str = "app.bsky.contact.removeData";
97    const METHOD: jacquard_common::xrpc::XrpcMethod =
98        jacquard_common::xrpc::XrpcMethod::Procedure("application/json");
99    type Response = RemoveDataResponse;
100}
101
102/** Endpoint marker for the `app.bsky.contact.removeData` procedure.
103
104Path: `/xrpc/app.bsky.contact.removeData`. The request payload type is `RemoveData<S>`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
105pub struct RemoveDataRequest;
106impl jacquard_common::xrpc::XrpcEndpoint for RemoveDataRequest {
107    const PATH: &'static str = "/xrpc/app.bsky.contact.removeData";
108    const METHOD: jacquard_common::xrpc::XrpcMethod =
109        jacquard_common::xrpc::XrpcMethod::Procedure("application/json");
110    type Request<S: BosStr> = RemoveData<S>;
111    type Response = RemoveDataResponse;
112}