jacquard_api/app_bsky/graph/
block.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: app.bsky.graph.block
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8/// Record declaring a 'block' relationship against another account. NOTE: blocks are public in Bluesky; see blog posts for details.
9#[jacquard_derive::lexicon]
10#[derive(
11    serde::Serialize,
12    serde::Deserialize,
13    Debug,
14    Clone,
15    PartialEq,
16    Eq,
17    jacquard_derive::IntoStatic,
18    bon::Builder
19)]
20#[serde(rename_all = "camelCase")]
21pub struct Block<'a> {
22    pub created_at: jacquard_common::types::string::Datetime,
23    /// DID of the account to be blocked.
24    #[serde(borrow)]
25    pub subject: jacquard_common::types::string::Did<'a>,
26}
27
28impl<'a> Block<'a> {
29    pub fn uri(
30        uri: impl Into<jacquard_common::CowStr<'a>>,
31    ) -> Result<
32        jacquard_common::types::uri::RecordUri<'a, BlockRecord>,
33        jacquard_common::types::uri::UriError,
34    > {
35        jacquard_common::types::uri::RecordUri::try_from_uri(
36            jacquard_common::types::string::AtUri::new_cow(uri.into())?,
37        )
38    }
39}
40
41/// Typed wrapper for GetRecord response with this collection's record type.
42#[derive(
43    serde::Serialize,
44    serde::Deserialize,
45    Debug,
46    Clone,
47    PartialEq,
48    Eq,
49    jacquard_derive::IntoStatic
50)]
51#[serde(rename_all = "camelCase")]
52pub struct BlockGetRecordOutput<'a> {
53    #[serde(skip_serializing_if = "std::option::Option::is_none")]
54    #[serde(borrow)]
55    pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
56    #[serde(borrow)]
57    pub uri: jacquard_common::types::string::AtUri<'a>,
58    #[serde(borrow)]
59    pub value: Block<'a>,
60}
61
62impl From<BlockGetRecordOutput<'_>> for Block<'_> {
63    fn from(output: BlockGetRecordOutput<'_>) -> Self {
64        use jacquard_common::IntoStatic;
65        output.value.into_static()
66    }
67}
68
69impl jacquard_common::types::collection::Collection for Block<'_> {
70    const NSID: &'static str = "app.bsky.graph.block";
71    type Record = BlockRecord;
72}
73
74/// Marker type for deserializing records from this collection.
75#[derive(Debug, serde::Serialize, serde::Deserialize)]
76pub struct BlockRecord;
77impl jacquard_common::xrpc::XrpcResp for BlockRecord {
78    const NSID: &'static str = "app.bsky.graph.block";
79    const ENCODING: &'static str = "application/json";
80    type Output<'de> = BlockGetRecordOutput<'de>;
81    type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
82}
83
84impl jacquard_common::types::collection::Collection for BlockRecord {
85    const NSID: &'static str = "app.bsky.graph.block";
86    type Record = BlockRecord;
87}