jacquard_api/sh_tangled/
string.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: sh.tangled.string
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    jacquard_derive::IntoStatic,
17    bon::Builder
18)]
19#[serde(rename_all = "camelCase")]
20pub struct String<'a> {
21    #[serde(borrow)]
22    #[builder(into)]
23    pub contents: jacquard_common::CowStr<'a>,
24    pub created_at: jacquard_common::types::string::Datetime,
25    #[serde(borrow)]
26    #[builder(into)]
27    pub description: jacquard_common::CowStr<'a>,
28    #[serde(borrow)]
29    #[builder(into)]
30    pub filename: jacquard_common::CowStr<'a>,
31}
32
33impl<'a> String<'a> {
34    pub fn uri(
35        uri: impl Into<jacquard_common::CowStr<'a>>,
36    ) -> Result<
37        jacquard_common::types::uri::RecordUri<'a, StringRecord>,
38        jacquard_common::types::uri::UriError,
39    > {
40        jacquard_common::types::uri::RecordUri::try_from_uri(
41            jacquard_common::types::string::AtUri::new_cow(uri.into())?,
42        )
43    }
44}
45
46/// Typed wrapper for GetRecord response with this collection's record type.
47#[derive(
48    serde::Serialize,
49    serde::Deserialize,
50    Debug,
51    Clone,
52    PartialEq,
53    Eq,
54    jacquard_derive::IntoStatic
55)]
56#[serde(rename_all = "camelCase")]
57pub struct StringGetRecordOutput<'a> {
58    #[serde(skip_serializing_if = "std::option::Option::is_none")]
59    #[serde(borrow)]
60    pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
61    #[serde(borrow)]
62    pub uri: jacquard_common::types::string::AtUri<'a>,
63    #[serde(borrow)]
64    pub value: String<'a>,
65}
66
67impl From<StringGetRecordOutput<'_>> for String<'_> {
68    fn from(output: StringGetRecordOutput<'_>) -> Self {
69        use jacquard_common::IntoStatic;
70        output.value.into_static()
71    }
72}
73
74impl jacquard_common::types::collection::Collection for String<'_> {
75    const NSID: &'static str = "sh.tangled.string";
76    type Record = StringRecord;
77}
78
79/// Marker type for deserializing records from this collection.
80#[derive(Debug, serde::Serialize, serde::Deserialize)]
81pub struct StringRecord;
82impl jacquard_common::xrpc::XrpcResp for StringRecord {
83    const NSID: &'static str = "sh.tangled.string";
84    const ENCODING: &'static str = "application/json";
85    type Output<'de> = StringGetRecordOutput<'de>;
86    type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
87}
88
89impl jacquard_common::types::collection::Collection for StringRecord {
90    const NSID: &'static str = "sh.tangled.string";
91    type Record = StringRecord;
92}