jacquard_api/app_bsky/bookmark/
create_bookmark.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: app.bsky.bookmark.createBookmark
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[jacquard_derive::lexicon]
9#[derive(
10    serde::Serialize,
11    serde::Deserialize,
12    Debug,
13    Clone,
14    PartialEq,
15    Eq,
16    bon::Builder,
17    jacquard_derive::IntoStatic
18)]
19#[serde(rename_all = "camelCase")]
20#[builder(start_fn = new)]
21pub struct CreateBookmark<'a> {
22    #[serde(borrow)]
23    pub cid: jacquard_common::types::string::Cid<'a>,
24    #[serde(borrow)]
25    pub uri: jacquard_common::types::string::AtUri<'a>,
26    #[serde(flatten)]
27    #[serde(borrow)]
28    #[builder(default)]
29    pub extra_data: ::std::collections::BTreeMap<
30        ::jacquard_common::smol_str::SmolStr,
31        ::jacquard_common::types::value::Data<'a>,
32    >,
33}
34
35#[jacquard_derive::open_union]
36#[derive(
37    serde::Serialize,
38    serde::Deserialize,
39    Debug,
40    Clone,
41    PartialEq,
42    Eq,
43    thiserror::Error,
44    miette::Diagnostic
45)]
46#[serde(tag = "error", content = "message")]
47#[serde(bound(deserialize = "'de: 'a"))]
48pub enum CreateBookmarkError<'a> {
49    ///The URI to be bookmarked is for an unsupported collection.
50    #[serde(rename = "UnsupportedCollection")]
51    UnsupportedCollection(std::option::Option<String>),
52}
53
54impl std::fmt::Display for CreateBookmarkError<'_> {
55    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
56        match self {
57            Self::UnsupportedCollection(msg) => {
58                write!(f, "UnsupportedCollection")?;
59                if let Some(msg) = msg {
60                    write!(f, ": {}", msg)?;
61                }
62                Ok(())
63            }
64            Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
65        }
66    }
67}
68
69impl jacquard_common::IntoStatic for CreateBookmarkError<'_> {
70    type Output = CreateBookmarkError<'static>;
71    fn into_static(self) -> Self::Output {
72        match self {
73            CreateBookmarkError::UnsupportedCollection(v) => {
74                CreateBookmarkError::UnsupportedCollection(v.into_static())
75            }
76            CreateBookmarkError::Unknown(v) => {
77                CreateBookmarkError::Unknown(v.into_static())
78            }
79        }
80    }
81}
82
83///Response type for
84///app.bsky.bookmark.createBookmark
85pub struct CreateBookmarkResponse;
86impl jacquard_common::xrpc::XrpcResp for CreateBookmarkResponse {
87    const NSID: &'static str = "app.bsky.bookmark.createBookmark";
88    const ENCODING: &'static str = "application/json";
89    type Output<'de> = ();
90    type Err<'de> = CreateBookmarkError<'de>;
91}
92
93impl<'de> jacquard_common::xrpc::XrpcRequest<'de> for CreateBookmark<'de> {
94    const NSID: &'static str = "app.bsky.bookmark.createBookmark";
95    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
96        "application/json",
97    );
98    type Response = CreateBookmarkResponse;
99}
100
101///Endpoint type for
102///app.bsky.bookmark.createBookmark
103pub struct CreateBookmarkRequest;
104impl jacquard_common::xrpc::XrpcEndpoint for CreateBookmarkRequest {
105    const PATH: &'static str = "/xrpc/app.bsky.bookmark.createBookmark";
106    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
107        "application/json",
108    );
109    type Request<'de> = CreateBookmark<'de>;
110    type Response = CreateBookmarkResponse;
111}