jacquard_api/sh_weaver/edit/
root.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: sh.weaver.edit.root
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8/// The starting point for edit history on a notebook.
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 Root<'a> {
22    #[serde(borrow)]
23    pub cid: jacquard_common::types::string::Cid<'a>,
24    #[serde(borrow)]
25    pub doc: crate::sh_weaver::edit::DocRef<'a>,
26    #[serde(borrow)]
27    pub snapshot: jacquard_common::types::blob::BlobRef<'a>,
28    #[serde(borrow)]
29    pub uri: jacquard_common::types::string::AtUri<'a>,
30}
31
32impl<'a> Root<'a> {
33    pub fn uri(
34        uri: impl Into<jacquard_common::CowStr<'a>>,
35    ) -> Result<
36        jacquard_common::types::uri::RecordUri<'a, RootRecord>,
37        jacquard_common::types::uri::UriError,
38    > {
39        jacquard_common::types::uri::RecordUri::try_from_uri(
40            jacquard_common::types::string::AtUri::new_cow(uri.into())?,
41        )
42    }
43}
44
45/// Typed wrapper for GetRecord response with this collection's record type.
46#[derive(
47    serde::Serialize,
48    serde::Deserialize,
49    Debug,
50    Clone,
51    PartialEq,
52    Eq,
53    jacquard_derive::IntoStatic
54)]
55#[serde(rename_all = "camelCase")]
56pub struct RootGetRecordOutput<'a> {
57    #[serde(skip_serializing_if = "std::option::Option::is_none")]
58    #[serde(borrow)]
59    pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
60    #[serde(borrow)]
61    pub uri: jacquard_common::types::string::AtUri<'a>,
62    #[serde(borrow)]
63    pub value: Root<'a>,
64}
65
66impl From<RootGetRecordOutput<'_>> for Root<'_> {
67    fn from(output: RootGetRecordOutput<'_>) -> Self {
68        use jacquard_common::IntoStatic;
69        output.value.into_static()
70    }
71}
72
73impl jacquard_common::types::collection::Collection for Root<'_> {
74    const NSID: &'static str = "sh.weaver.edit.root";
75    type Record = RootRecord;
76}
77
78/// Marker type for deserializing records from this collection.
79#[derive(Debug, serde::Serialize, serde::Deserialize)]
80pub struct RootRecord;
81impl jacquard_common::xrpc::XrpcResp for RootRecord {
82    const NSID: &'static str = "sh.weaver.edit.root";
83    const ENCODING: &'static str = "application/json";
84    type Output<'de> = RootGetRecordOutput<'de>;
85    type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
86}
87
88impl jacquard_common::types::collection::Collection for RootRecord {
89    const NSID: &'static str = "sh.weaver.edit.root";
90    type Record = RootRecord;
91}