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    jacquard_derive::IntoStatic
46)]
47#[serde(tag = "error", content = "message")]
48#[serde(bound(deserialize = "'de: 'a"))]
49pub enum CreateBookmarkError<'a> {
50    /// The URI to be bookmarked is for an unsupported collection.
51    #[serde(rename = "UnsupportedCollection")]
52    UnsupportedCollection(std::option::Option<String>),
53}
54
55impl std::fmt::Display for CreateBookmarkError<'_> {
56    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
57        match self {
58            Self::UnsupportedCollection(msg) => {
59                write!(f, "UnsupportedCollection")?;
60                if let Some(msg) = msg {
61                    write!(f, ": {}", msg)?;
62                }
63                Ok(())
64            }
65            Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
66        }
67    }
68}
69
70/// Response type for
71///app.bsky.bookmark.createBookmark
72pub struct CreateBookmarkResponse;
73impl jacquard_common::xrpc::XrpcResp for CreateBookmarkResponse {
74    const NSID: &'static str = "app.bsky.bookmark.createBookmark";
75    const ENCODING: &'static str = "application/json";
76    type Output<'de> = ();
77    type Err<'de> = CreateBookmarkError<'de>;
78}
79
80impl<'a> jacquard_common::xrpc::XrpcRequest for CreateBookmark<'a> {
81    const NSID: &'static str = "app.bsky.bookmark.createBookmark";
82    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
83        "application/json",
84    );
85    type Response = CreateBookmarkResponse;
86}
87
88/// Endpoint type for
89///app.bsky.bookmark.createBookmark
90pub struct CreateBookmarkRequest;
91impl jacquard_common::xrpc::XrpcEndpoint for CreateBookmarkRequest {
92    const PATH: &'static str = "/xrpc/app.bsky.bookmark.createBookmark";
93    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
94        "application/json",
95    );
96    type Request<'de> = CreateBookmark<'de>;
97    type Response = CreateBookmarkResponse;
98}