Skip to main content

jacquard_api/sh_weaver/notebook/
resolve_version_conflict.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: sh.weaver.notebook.resolveVersionConflict
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::CowStr;
14use jacquard_common::types::string::AtUri;
15use jacquard_derive::{IntoStatic, lexicon, open_union};
16use serde::{Serialize, Deserialize};
17use crate::sh_weaver::collab::CollaborationStateView;
18use crate::sh_weaver::notebook::PublishedVersionView;
19
20#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
21#[serde(rename_all = "camelCase")]
22pub struct ResolveVersionConflict<'a> {
23    #[serde(borrow)]
24    pub uris: Vec<AtUri<'a>>,
25}
26
27
28#[lexicon]
29#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
30#[serde(rename_all = "camelCase")]
31pub struct ResolveVersionConflictOutput<'a> {
32    #[serde(borrow)]
33    pub canonical: PublishedVersionView<'a>,
34    #[serde(skip_serializing_if = "Option::is_none")]
35    #[serde(borrow)]
36    pub collaboration_state: Option<CollaborationStateView<'a>>,
37    #[serde(borrow)]
38    pub related: Vec<PublishedVersionView<'a>>,
39}
40
41
42#[open_union]
43#[derive(
44    Serialize,
45    Deserialize,
46    Debug,
47    Clone,
48    PartialEq,
49    Eq,
50    thiserror::Error,
51    miette::Diagnostic,
52    IntoStatic
53)]
54
55#[serde(tag = "error", content = "message")]
56#[serde(bound(deserialize = "'de: 'a"))]
57pub enum ResolveVersionConflictError<'a> {
58    /// The URIs don't appear to be related versions
59    #[serde(rename = "NoRelatedVersions")]
60    NoRelatedVersions(Option<CowStr<'a>>),
61}
62
63impl core::fmt::Display for ResolveVersionConflictError<'_> {
64    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
65        match self {
66            Self::NoRelatedVersions(msg) => {
67                write!(f, "NoRelatedVersions")?;
68                if let Some(msg) = msg {
69                    write!(f, ": {}", msg)?;
70                }
71                Ok(())
72            }
73            Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
74        }
75    }
76}
77
78/// Response type for sh.weaver.notebook.resolveVersionConflict
79pub struct ResolveVersionConflictResponse;
80impl jacquard_common::xrpc::XrpcResp for ResolveVersionConflictResponse {
81    const NSID: &'static str = "sh.weaver.notebook.resolveVersionConflict";
82    const ENCODING: &'static str = "application/json";
83    type Output<'de> = ResolveVersionConflictOutput<'de>;
84    type Err<'de> = ResolveVersionConflictError<'de>;
85}
86
87impl<'a> jacquard_common::xrpc::XrpcRequest for ResolveVersionConflict<'a> {
88    const NSID: &'static str = "sh.weaver.notebook.resolveVersionConflict";
89    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
90    type Response = ResolveVersionConflictResponse;
91}
92
93/// Endpoint type for sh.weaver.notebook.resolveVersionConflict
94pub struct ResolveVersionConflictRequest;
95impl jacquard_common::xrpc::XrpcEndpoint for ResolveVersionConflictRequest {
96    const PATH: &'static str = "/xrpc/sh.weaver.notebook.resolveVersionConflict";
97    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
98    type Request<'de> = ResolveVersionConflict<'de>;
99    type Response = ResolveVersionConflictResponse;
100}
101
102pub mod resolve_version_conflict_state {
103
104    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
105    #[allow(unused)]
106    use ::core::marker::PhantomData;
107    mod sealed {
108        pub trait Sealed {}
109    }
110    /// State trait tracking which required fields have been set
111    pub trait State: sealed::Sealed {
112        type Uris;
113    }
114    /// Empty state - all required fields are unset
115    pub struct Empty(());
116    impl sealed::Sealed for Empty {}
117    impl State for Empty {
118        type Uris = Unset;
119    }
120    ///State transition - sets the `uris` field to Set
121    pub struct SetUris<S: State = Empty>(PhantomData<fn() -> S>);
122    impl<S: State> sealed::Sealed for SetUris<S> {}
123    impl<S: State> State for SetUris<S> {
124        type Uris = Set<members::uris>;
125    }
126    /// Marker types for field names
127    #[allow(non_camel_case_types)]
128    pub mod members {
129        ///Marker type for the `uris` field
130        pub struct uris(());
131    }
132}
133
134/// Builder for constructing an instance of this type
135pub struct ResolveVersionConflictBuilder<'a, S: resolve_version_conflict_state::State> {
136    _state: PhantomData<fn() -> S>,
137    _fields: (Option<Vec<AtUri<'a>>>,),
138    _lifetime: PhantomData<&'a ()>,
139}
140
141impl<'a> ResolveVersionConflict<'a> {
142    /// Create a new builder for this type
143    pub fn new() -> ResolveVersionConflictBuilder<
144        'a,
145        resolve_version_conflict_state::Empty,
146    > {
147        ResolveVersionConflictBuilder::new()
148    }
149}
150
151impl<'a> ResolveVersionConflictBuilder<'a, resolve_version_conflict_state::Empty> {
152    /// Create a new builder with all fields unset
153    pub fn new() -> Self {
154        ResolveVersionConflictBuilder {
155            _state: PhantomData,
156            _fields: (None,),
157            _lifetime: PhantomData,
158        }
159    }
160}
161
162impl<'a, S> ResolveVersionConflictBuilder<'a, S>
163where
164    S: resolve_version_conflict_state::State,
165    S::Uris: resolve_version_conflict_state::IsUnset,
166{
167    /// Set the `uris` field (required)
168    pub fn uris(
169        mut self,
170        value: impl Into<Vec<AtUri<'a>>>,
171    ) -> ResolveVersionConflictBuilder<'a, resolve_version_conflict_state::SetUris<S>> {
172        self._fields.0 = Option::Some(value.into());
173        ResolveVersionConflictBuilder {
174            _state: PhantomData,
175            _fields: self._fields,
176            _lifetime: PhantomData,
177        }
178    }
179}
180
181impl<'a, S> ResolveVersionConflictBuilder<'a, S>
182where
183    S: resolve_version_conflict_state::State,
184    S::Uris: resolve_version_conflict_state::IsSet,
185{
186    /// Build the final struct
187    pub fn build(self) -> ResolveVersionConflict<'a> {
188        ResolveVersionConflict {
189            uris: self._fields.0.unwrap(),
190        }
191    }
192}