jacquard_api/sh_weaver/edit/
cursor.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: sh.weaver.edit.cursor
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 ContainerId<'a> {
21    #[serde(borrow)]
22    pub value: ContainerIdValue<'a>,
23}
24
25#[jacquard_derive::open_union]
26#[derive(
27    serde::Serialize,
28    serde::Deserialize,
29    Debug,
30    Clone,
31    PartialEq,
32    Eq,
33    jacquard_derive::IntoStatic
34)]
35#[serde(tag = "$type")]
36#[serde(bound(deserialize = "'de: 'a"))]
37pub enum ContainerIdValue<'a> {
38    #[serde(rename = "sh.weaver.edit.cursor#normalContainerId")]
39    NormalContainerId(Box<crate::sh_weaver::edit::cursor::NormalContainerId<'a>>),
40    #[serde(rename = "sh.weaver.edit.cursor#rootContainerId")]
41    RootContainerId(Box<crate::sh_weaver::edit::cursor::RootContainerId<'a>>),
42}
43
44#[jacquard_derive::lexicon]
45#[derive(
46    serde::Serialize,
47    serde::Deserialize,
48    Debug,
49    Clone,
50    PartialEq,
51    Eq,
52    jacquard_derive::IntoStatic,
53    bon::Builder
54)]
55#[serde(rename_all = "camelCase")]
56pub struct CursorSide<'a> {
57    /// The side of an item the cursor is on (left = -1, right = 1, middle = 0)
58    pub value: i64,
59}
60
61#[jacquard_derive::lexicon]
62#[derive(
63    serde::Serialize,
64    serde::Deserialize,
65    Debug,
66    Clone,
67    PartialEq,
68    Eq,
69    jacquard_derive::IntoStatic,
70    bon::Builder
71)]
72#[serde(rename_all = "camelCase")]
73pub struct Id<'a> {
74    pub counter: i64,
75    pub peer: i64,
76}
77
78/// An edit record for a notebook.
79#[jacquard_derive::lexicon]
80#[derive(
81    serde::Serialize,
82    serde::Deserialize,
83    Debug,
84    Clone,
85    PartialEq,
86    Eq,
87    jacquard_derive::IntoStatic,
88    bon::Builder
89)]
90#[serde(rename_all = "camelCase")]
91pub struct Cursor<'a> {
92    #[serde(borrow)]
93    pub container: crate::sh_weaver::edit::cursor::ContainerId<'a>,
94    #[serde(skip_serializing_if = "std::option::Option::is_none")]
95    #[builder(into)]
96    #[serde(borrow)]
97    pub id: Option<crate::sh_weaver::edit::cursor::Id<'a>>,
98    #[serde(skip_serializing_if = "std::option::Option::is_none")]
99    #[builder(into)]
100    #[serde(borrow)]
101    pub side: Option<crate::sh_weaver::edit::cursor::CursorSide<'a>>,
102}
103
104impl<'a> Cursor<'a> {
105    pub fn uri(
106        uri: impl Into<jacquard_common::CowStr<'a>>,
107    ) -> Result<
108        jacquard_common::types::uri::RecordUri<'a, CursorRecord>,
109        jacquard_common::types::uri::UriError,
110    > {
111        jacquard_common::types::uri::RecordUri::try_from_uri(
112            jacquard_common::types::string::AtUri::new_cow(uri.into())?,
113        )
114    }
115}
116
117/// Typed wrapper for GetRecord response with this collection's record type.
118#[derive(
119    serde::Serialize,
120    serde::Deserialize,
121    Debug,
122    Clone,
123    PartialEq,
124    Eq,
125    jacquard_derive::IntoStatic
126)]
127#[serde(rename_all = "camelCase")]
128pub struct CursorGetRecordOutput<'a> {
129    #[serde(skip_serializing_if = "std::option::Option::is_none")]
130    #[serde(borrow)]
131    pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
132    #[serde(borrow)]
133    pub uri: jacquard_common::types::string::AtUri<'a>,
134    #[serde(borrow)]
135    pub value: Cursor<'a>,
136}
137
138impl From<CursorGetRecordOutput<'_>> for Cursor<'_> {
139    fn from(output: CursorGetRecordOutput<'_>) -> Self {
140        use jacquard_common::IntoStatic;
141        output.value.into_static()
142    }
143}
144
145impl jacquard_common::types::collection::Collection for Cursor<'_> {
146    const NSID: &'static str = "sh.weaver.edit.cursor";
147    type Record = CursorRecord;
148}
149
150/// Marker type for deserializing records from this collection.
151#[derive(Debug, serde::Serialize, serde::Deserialize)]
152pub struct CursorRecord;
153impl jacquard_common::xrpc::XrpcResp for CursorRecord {
154    const NSID: &'static str = "sh.weaver.edit.cursor";
155    const ENCODING: &'static str = "application/json";
156    type Output<'de> = CursorGetRecordOutput<'de>;
157    type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
158}
159
160impl jacquard_common::types::collection::Collection for CursorRecord {
161    const NSID: &'static str = "sh.weaver.edit.cursor";
162    type Record = CursorRecord;
163}
164
165#[jacquard_derive::lexicon]
166#[derive(
167    serde::Serialize,
168    serde::Deserialize,
169    Debug,
170    Clone,
171    PartialEq,
172    Eq,
173    jacquard_derive::IntoStatic,
174    bon::Builder
175)]
176#[serde(rename_all = "camelCase")]
177pub struct NormalContainerId<'a> {
178    #[serde(borrow)]
179    #[builder(into)]
180    pub container_type: jacquard_common::CowStr<'a>,
181    pub counter: i64,
182    pub peer: i64,
183}
184
185#[jacquard_derive::lexicon]
186#[derive(
187    serde::Serialize,
188    serde::Deserialize,
189    Debug,
190    Clone,
191    PartialEq,
192    Eq,
193    jacquard_derive::IntoStatic,
194    Default
195)]
196#[serde(rename_all = "camelCase")]
197pub struct RootContainerId<'a> {
198    #[serde(borrow)]
199    pub container_type: jacquard_common::CowStr<'a>,
200    #[serde(borrow)]
201    pub name: jacquard_common::CowStr<'a>,
202}