pub mod cursor;
pub mod diff;
pub mod draft;
pub mod get_branch;
pub mod get_contributors;
pub mod get_edit_history;
pub mod get_edit_tree;
pub mod list_drafts;
pub mod root;
#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::{AtUri, Cid, Datetime};
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::com_atproto::repo::strong_ref::StrongRef;
use crate::sh_weaver::actor::ProfileViewBasic;
use crate::sh_weaver::edit;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct DocRef<S: BosStr = DefaultStr> {
pub value: DocRefValue<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum DocRefValue<S: BosStr = DefaultStr> {
#[serde(rename = "sh.weaver.edit.defs#notebookRef")]
NotebookRef(Box<edit::NotebookRef<S>>),
#[serde(rename = "sh.weaver.edit.defs#entryRef")]
EntryRef(Box<edit::EntryRef<S>>),
#[serde(rename = "sh.weaver.edit.defs#draftRef")]
DraftRef(Box<edit::DraftRef<S>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct DraftRef<S: BosStr = DefaultStr> {
pub draft_key: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct EditBranchView<S: BosStr = DefaultStr> {
pub author: ProfileViewBasic<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub diverges_from: Option<StrongRef<S>>,
pub head: StrongRef<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub is_merged: Option<bool>,
pub last_updated: Datetime,
pub length: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub root: Option<StrongRef<S>>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct EditHistoryEntry<S: BosStr = DefaultStr> {
pub author: ProfileViewBasic<S>,
pub cid: Cid<S>,
pub created_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub has_inline_diff: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub prev_ref: Option<StrongRef<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub root_ref: Option<StrongRef<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub snapshot_cid: Option<Cid<S>>,
pub r#type: EditHistoryEntryType<S>,
pub uri: AtUri<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum EditHistoryEntryType<S: BosStr = DefaultStr> {
Root,
Diff,
Other(S),
}
impl<S: BosStr> EditHistoryEntryType<S> {
pub fn as_str(&self) -> &str {
match self {
Self::Root => "root",
Self::Diff => "diff",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"root" => Self::Root,
"diff" => Self::Diff,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for EditHistoryEntryType<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for EditHistoryEntryType<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for EditHistoryEntryType<S> {
fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
where
Ser: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for EditHistoryEntryType<S> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = S::deserialize(deserializer)?;
Ok(Self::from_value(s))
}
}
impl<S: BosStr + Default> Default for EditHistoryEntryType<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for EditHistoryEntryType<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = EditHistoryEntryType<S::Output>;
fn into_static(self) -> Self::Output {
match self {
EditHistoryEntryType::Root => EditHistoryEntryType::Root,
EditHistoryEntryType::Diff => EditHistoryEntryType::Diff,
EditHistoryEntryType::Other(v) => {
EditHistoryEntryType::Other(v.into_static())
}
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct EditTreeView<S: BosStr = DefaultStr> {
pub branches: Vec<edit::EditBranchView<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub conflict_points: Option<Vec<StrongRef<S>>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub has_conflicts: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub main_branch: Option<edit::EditBranchView<S>>,
pub resource: StrongRef<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct EntryRef<S: BosStr = DefaultStr> {
pub entry: StrongRef<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct NotebookRef<S: BosStr = DefaultStr> {
pub notebook: StrongRef<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> LexiconSchema for DocRef<S> {
fn nsid() -> &'static str {
"sh.weaver.edit.defs"
}
fn def_name() -> &'static str {
"docRef"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_weaver_edit_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for DraftRef<S> {
fn nsid() -> &'static str {
"sh.weaver.edit.defs"
}
fn def_name() -> &'static str {
"draftRef"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_weaver_edit_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.draft_key;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 200usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("draft_key"),
max: 200usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for EditBranchView<S> {
fn nsid() -> &'static str {
"sh.weaver.edit.defs"
}
fn def_name() -> &'static str {
"editBranchView"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_weaver_edit_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for EditHistoryEntry<S> {
fn nsid() -> &'static str {
"sh.weaver.edit.defs"
}
fn def_name() -> &'static str {
"editHistoryEntry"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_weaver_edit_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for EditTreeView<S> {
fn nsid() -> &'static str {
"sh.weaver.edit.defs"
}
fn def_name() -> &'static str {
"editTreeView"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_weaver_edit_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for EntryRef<S> {
fn nsid() -> &'static str {
"sh.weaver.edit.defs"
}
fn def_name() -> &'static str {
"entryRef"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_weaver_edit_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for NotebookRef<S> {
fn nsid() -> &'static str {
"sh.weaver.edit.defs"
}
fn def_name() -> &'static str {
"notebookRef"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_weaver_edit_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod doc_ref_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Value;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Value = Unset;
}
pub struct SetValue<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetValue<St> {}
impl<St: State> State for SetValue<St> {
type Value = Set<members::value>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct value(());
}
}
pub struct DocRefBuilder<S: BosStr, St: doc_ref_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<DocRefValue<S>>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> DocRef<S> {
pub fn new() -> DocRefBuilder<S, doc_ref_state::Empty> {
DocRefBuilder::new()
}
}
impl<S: BosStr> DocRefBuilder<S, doc_ref_state::Empty> {
pub fn new() -> Self {
DocRefBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DocRefBuilder<S, St>
where
St: doc_ref_state::State,
St::Value: doc_ref_state::IsUnset,
{
pub fn value(
mut self,
value: impl Into<DocRefValue<S>>,
) -> DocRefBuilder<S, doc_ref_state::SetValue<St>> {
self._fields.0 = Option::Some(value.into());
DocRefBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DocRefBuilder<S, St>
where
St: doc_ref_state::State,
St::Value: doc_ref_state::IsSet,
{
pub fn build(self) -> DocRef<S> {
DocRef {
value: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> DocRef<S> {
DocRef {
value: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_sh_weaver_edit_defs() -> LexiconDoc<'static> {
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
use alloc::collections::BTreeMap;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("sh.weaver.edit.defs"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("docRef"),
LexUserType::Object(LexObject {
required: Some(vec![SmolStr::new_static("value")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("value"),
LexObjectProperty::Union(LexRefUnion {
refs: vec![
CowStr::new_static("#notebookRef"),
CowStr::new_static("#entryRef"),
CowStr::new_static("#draftRef")
],
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("draftRef"),
LexUserType::Object(LexObject {
required: Some(vec![SmolStr::new_static("draftKey")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("draftKey"),
LexObjectProperty::String(LexString {
max_length: Some(200usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("editBranchView"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"A branch/fork in edit history (for when collaborators diverge).",
),
),
required: Some(
vec![
SmolStr::new_static("head"), SmolStr::new_static("author"),
SmolStr::new_static("length"),
SmolStr::new_static("lastUpdated")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("author"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static(
"sh.weaver.actor.defs#profileViewBasic",
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("divergesFrom"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("head"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("isMerged"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("lastUpdated"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("length"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("root"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("editHistoryEntry"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Summary of an edit (root or diff) for history queries.",
),
),
required: Some(
vec![
SmolStr::new_static("uri"), SmolStr::new_static("cid"),
SmolStr::new_static("author"),
SmolStr::new_static("createdAt"), SmolStr::new_static("type")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("author"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static(
"sh.weaver.actor.defs#profileViewBasic",
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("cid"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Cid),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("hasInlineDiff"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("prevRef"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("rootRef"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("snapshotCid"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Cid),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("type"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map.insert(
SmolStr::new_static("uri"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("editTreeView"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Full tree structure showing all branches for a resource.",
),
),
required: Some(
vec![
SmolStr::new_static("resource"),
SmolStr::new_static("branches")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("branches"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#editBranchView"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("conflictPoints"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static("Diffs where branches diverge"),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("hasConflicts"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("mainBranch"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#editBranchView"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("resource"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("entryRef"),
LexUserType::Object(LexObject {
required: Some(vec![SmolStr::new_static("entry")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("entry"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("notebookRef"),
LexUserType::Object(LexObject {
required: Some(vec![SmolStr::new_static("notebook")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("notebook"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod edit_branch_view_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Head;
type Length;
type LastUpdated;
type Author;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Head = Unset;
type Length = Unset;
type LastUpdated = Unset;
type Author = Unset;
}
pub struct SetHead<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetHead<St> {}
impl<St: State> State for SetHead<St> {
type Head = Set<members::head>;
type Length = St::Length;
type LastUpdated = St::LastUpdated;
type Author = St::Author;
}
pub struct SetLength<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetLength<St> {}
impl<St: State> State for SetLength<St> {
type Head = St::Head;
type Length = Set<members::length>;
type LastUpdated = St::LastUpdated;
type Author = St::Author;
}
pub struct SetLastUpdated<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetLastUpdated<St> {}
impl<St: State> State for SetLastUpdated<St> {
type Head = St::Head;
type Length = St::Length;
type LastUpdated = Set<members::last_updated>;
type Author = St::Author;
}
pub struct SetAuthor<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetAuthor<St> {}
impl<St: State> State for SetAuthor<St> {
type Head = St::Head;
type Length = St::Length;
type LastUpdated = St::LastUpdated;
type Author = Set<members::author>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct head(());
pub struct length(());
pub struct last_updated(());
pub struct author(());
}
}
pub struct EditBranchViewBuilder<S: BosStr, St: edit_branch_view_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<ProfileViewBasic<S>>,
Option<StrongRef<S>>,
Option<StrongRef<S>>,
Option<bool>,
Option<Datetime>,
Option<i64>,
Option<StrongRef<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> EditBranchView<S> {
pub fn new() -> EditBranchViewBuilder<S, edit_branch_view_state::Empty> {
EditBranchViewBuilder::new()
}
}
impl<S: BosStr> EditBranchViewBuilder<S, edit_branch_view_state::Empty> {
pub fn new() -> Self {
EditBranchViewBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> EditBranchViewBuilder<S, St>
where
St: edit_branch_view_state::State,
St::Author: edit_branch_view_state::IsUnset,
{
pub fn author(
mut self,
value: impl Into<ProfileViewBasic<S>>,
) -> EditBranchViewBuilder<S, edit_branch_view_state::SetAuthor<St>> {
self._fields.0 = Option::Some(value.into());
EditBranchViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: edit_branch_view_state::State> EditBranchViewBuilder<S, St> {
pub fn diverges_from(mut self, value: impl Into<Option<StrongRef<S>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_diverges_from(mut self, value: Option<StrongRef<S>>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> EditBranchViewBuilder<S, St>
where
St: edit_branch_view_state::State,
St::Head: edit_branch_view_state::IsUnset,
{
pub fn head(
mut self,
value: impl Into<StrongRef<S>>,
) -> EditBranchViewBuilder<S, edit_branch_view_state::SetHead<St>> {
self._fields.2 = Option::Some(value.into());
EditBranchViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: edit_branch_view_state::State> EditBranchViewBuilder<S, St> {
pub fn is_merged(mut self, value: impl Into<Option<bool>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_is_merged(mut self, value: Option<bool>) -> Self {
self._fields.3 = value;
self
}
}
impl<S: BosStr, St> EditBranchViewBuilder<S, St>
where
St: edit_branch_view_state::State,
St::LastUpdated: edit_branch_view_state::IsUnset,
{
pub fn last_updated(
mut self,
value: impl Into<Datetime>,
) -> EditBranchViewBuilder<S, edit_branch_view_state::SetLastUpdated<St>> {
self._fields.4 = Option::Some(value.into());
EditBranchViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> EditBranchViewBuilder<S, St>
where
St: edit_branch_view_state::State,
St::Length: edit_branch_view_state::IsUnset,
{
pub fn length(
mut self,
value: impl Into<i64>,
) -> EditBranchViewBuilder<S, edit_branch_view_state::SetLength<St>> {
self._fields.5 = Option::Some(value.into());
EditBranchViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: edit_branch_view_state::State> EditBranchViewBuilder<S, St> {
pub fn root(mut self, value: impl Into<Option<StrongRef<S>>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_root(mut self, value: Option<StrongRef<S>>) -> Self {
self._fields.6 = value;
self
}
}
impl<S: BosStr, St> EditBranchViewBuilder<S, St>
where
St: edit_branch_view_state::State,
St::Head: edit_branch_view_state::IsSet,
St::Length: edit_branch_view_state::IsSet,
St::LastUpdated: edit_branch_view_state::IsSet,
St::Author: edit_branch_view_state::IsSet,
{
pub fn build(self) -> EditBranchView<S> {
EditBranchView {
author: self._fields.0.unwrap(),
diverges_from: self._fields.1,
head: self._fields.2.unwrap(),
is_merged: self._fields.3,
last_updated: self._fields.4.unwrap(),
length: self._fields.5.unwrap(),
root: self._fields.6,
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> EditBranchView<S> {
EditBranchView {
author: self._fields.0.unwrap(),
diverges_from: self._fields.1,
head: self._fields.2.unwrap(),
is_merged: self._fields.3,
last_updated: self._fields.4.unwrap(),
length: self._fields.5.unwrap(),
root: self._fields.6,
extra_data: Some(extra_data),
}
}
}
pub mod edit_history_entry_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Cid;
type Uri;
type CreatedAt;
type Type;
type Author;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Cid = Unset;
type Uri = Unset;
type CreatedAt = Unset;
type Type = Unset;
type Author = Unset;
}
pub struct SetCid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCid<St> {}
impl<St: State> State for SetCid<St> {
type Cid = Set<members::cid>;
type Uri = St::Uri;
type CreatedAt = St::CreatedAt;
type Type = St::Type;
type Author = St::Author;
}
pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetUri<St> {}
impl<St: State> State for SetUri<St> {
type Cid = St::Cid;
type Uri = Set<members::uri>;
type CreatedAt = St::CreatedAt;
type Type = St::Type;
type Author = St::Author;
}
pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
impl<St: State> State for SetCreatedAt<St> {
type Cid = St::Cid;
type Uri = St::Uri;
type CreatedAt = Set<members::created_at>;
type Type = St::Type;
type Author = St::Author;
}
pub struct SetType<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetType<St> {}
impl<St: State> State for SetType<St> {
type Cid = St::Cid;
type Uri = St::Uri;
type CreatedAt = St::CreatedAt;
type Type = Set<members::r#type>;
type Author = St::Author;
}
pub struct SetAuthor<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetAuthor<St> {}
impl<St: State> State for SetAuthor<St> {
type Cid = St::Cid;
type Uri = St::Uri;
type CreatedAt = St::CreatedAt;
type Type = St::Type;
type Author = Set<members::author>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct cid(());
pub struct uri(());
pub struct created_at(());
pub struct r#type(());
pub struct author(());
}
}
pub struct EditHistoryEntryBuilder<S: BosStr, St: edit_history_entry_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<ProfileViewBasic<S>>,
Option<Cid<S>>,
Option<Datetime>,
Option<bool>,
Option<StrongRef<S>>,
Option<StrongRef<S>>,
Option<Cid<S>>,
Option<EditHistoryEntryType<S>>,
Option<AtUri<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> EditHistoryEntry<S> {
pub fn new() -> EditHistoryEntryBuilder<S, edit_history_entry_state::Empty> {
EditHistoryEntryBuilder::new()
}
}
impl<S: BosStr> EditHistoryEntryBuilder<S, edit_history_entry_state::Empty> {
pub fn new() -> Self {
EditHistoryEntryBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> EditHistoryEntryBuilder<S, St>
where
St: edit_history_entry_state::State,
St::Author: edit_history_entry_state::IsUnset,
{
pub fn author(
mut self,
value: impl Into<ProfileViewBasic<S>>,
) -> EditHistoryEntryBuilder<S, edit_history_entry_state::SetAuthor<St>> {
self._fields.0 = Option::Some(value.into());
EditHistoryEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> EditHistoryEntryBuilder<S, St>
where
St: edit_history_entry_state::State,
St::Cid: edit_history_entry_state::IsUnset,
{
pub fn cid(
mut self,
value: impl Into<Cid<S>>,
) -> EditHistoryEntryBuilder<S, edit_history_entry_state::SetCid<St>> {
self._fields.1 = Option::Some(value.into());
EditHistoryEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> EditHistoryEntryBuilder<S, St>
where
St: edit_history_entry_state::State,
St::CreatedAt: edit_history_entry_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> EditHistoryEntryBuilder<S, edit_history_entry_state::SetCreatedAt<St>> {
self._fields.2 = Option::Some(value.into());
EditHistoryEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: edit_history_entry_state::State> EditHistoryEntryBuilder<S, St> {
pub fn has_inline_diff(mut self, value: impl Into<Option<bool>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_has_inline_diff(mut self, value: Option<bool>) -> Self {
self._fields.3 = value;
self
}
}
impl<S: BosStr, St: edit_history_entry_state::State> EditHistoryEntryBuilder<S, St> {
pub fn prev_ref(mut self, value: impl Into<Option<StrongRef<S>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_prev_ref(mut self, value: Option<StrongRef<S>>) -> Self {
self._fields.4 = value;
self
}
}
impl<S: BosStr, St: edit_history_entry_state::State> EditHistoryEntryBuilder<S, St> {
pub fn root_ref(mut self, value: impl Into<Option<StrongRef<S>>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_root_ref(mut self, value: Option<StrongRef<S>>) -> Self {
self._fields.5 = value;
self
}
}
impl<S: BosStr, St: edit_history_entry_state::State> EditHistoryEntryBuilder<S, St> {
pub fn snapshot_cid(mut self, value: impl Into<Option<Cid<S>>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_snapshot_cid(mut self, value: Option<Cid<S>>) -> Self {
self._fields.6 = value;
self
}
}
impl<S: BosStr, St> EditHistoryEntryBuilder<S, St>
where
St: edit_history_entry_state::State,
St::Type: edit_history_entry_state::IsUnset,
{
pub fn r#type(
mut self,
value: impl Into<EditHistoryEntryType<S>>,
) -> EditHistoryEntryBuilder<S, edit_history_entry_state::SetType<St>> {
self._fields.7 = Option::Some(value.into());
EditHistoryEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> EditHistoryEntryBuilder<S, St>
where
St: edit_history_entry_state::State,
St::Uri: edit_history_entry_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<AtUri<S>>,
) -> EditHistoryEntryBuilder<S, edit_history_entry_state::SetUri<St>> {
self._fields.8 = Option::Some(value.into());
EditHistoryEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> EditHistoryEntryBuilder<S, St>
where
St: edit_history_entry_state::State,
St::Cid: edit_history_entry_state::IsSet,
St::Uri: edit_history_entry_state::IsSet,
St::CreatedAt: edit_history_entry_state::IsSet,
St::Type: edit_history_entry_state::IsSet,
St::Author: edit_history_entry_state::IsSet,
{
pub fn build(self) -> EditHistoryEntry<S> {
EditHistoryEntry {
author: self._fields.0.unwrap(),
cid: self._fields.1.unwrap(),
created_at: self._fields.2.unwrap(),
has_inline_diff: self._fields.3,
prev_ref: self._fields.4,
root_ref: self._fields.5,
snapshot_cid: self._fields.6,
r#type: self._fields.7.unwrap(),
uri: self._fields.8.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> EditHistoryEntry<S> {
EditHistoryEntry {
author: self._fields.0.unwrap(),
cid: self._fields.1.unwrap(),
created_at: self._fields.2.unwrap(),
has_inline_diff: self._fields.3,
prev_ref: self._fields.4,
root_ref: self._fields.5,
snapshot_cid: self._fields.6,
r#type: self._fields.7.unwrap(),
uri: self._fields.8.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod edit_tree_view_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Resource;
type Branches;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Resource = Unset;
type Branches = Unset;
}
pub struct SetResource<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetResource<St> {}
impl<St: State> State for SetResource<St> {
type Resource = Set<members::resource>;
type Branches = St::Branches;
}
pub struct SetBranches<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetBranches<St> {}
impl<St: State> State for SetBranches<St> {
type Resource = St::Resource;
type Branches = Set<members::branches>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct resource(());
pub struct branches(());
}
}
pub struct EditTreeViewBuilder<S: BosStr, St: edit_tree_view_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Vec<edit::EditBranchView<S>>>,
Option<Vec<StrongRef<S>>>,
Option<bool>,
Option<edit::EditBranchView<S>>,
Option<StrongRef<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> EditTreeView<S> {
pub fn new() -> EditTreeViewBuilder<S, edit_tree_view_state::Empty> {
EditTreeViewBuilder::new()
}
}
impl<S: BosStr> EditTreeViewBuilder<S, edit_tree_view_state::Empty> {
pub fn new() -> Self {
EditTreeViewBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> EditTreeViewBuilder<S, St>
where
St: edit_tree_view_state::State,
St::Branches: edit_tree_view_state::IsUnset,
{
pub fn branches(
mut self,
value: impl Into<Vec<edit::EditBranchView<S>>>,
) -> EditTreeViewBuilder<S, edit_tree_view_state::SetBranches<St>> {
self._fields.0 = Option::Some(value.into());
EditTreeViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: edit_tree_view_state::State> EditTreeViewBuilder<S, St> {
pub fn conflict_points(
mut self,
value: impl Into<Option<Vec<StrongRef<S>>>>,
) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_conflict_points(mut self, value: Option<Vec<StrongRef<S>>>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St: edit_tree_view_state::State> EditTreeViewBuilder<S, St> {
pub fn has_conflicts(mut self, value: impl Into<Option<bool>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_has_conflicts(mut self, value: Option<bool>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St: edit_tree_view_state::State> EditTreeViewBuilder<S, St> {
pub fn main_branch(
mut self,
value: impl Into<Option<edit::EditBranchView<S>>>,
) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_main_branch(mut self, value: Option<edit::EditBranchView<S>>) -> Self {
self._fields.3 = value;
self
}
}
impl<S: BosStr, St> EditTreeViewBuilder<S, St>
where
St: edit_tree_view_state::State,
St::Resource: edit_tree_view_state::IsUnset,
{
pub fn resource(
mut self,
value: impl Into<StrongRef<S>>,
) -> EditTreeViewBuilder<S, edit_tree_view_state::SetResource<St>> {
self._fields.4 = Option::Some(value.into());
EditTreeViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> EditTreeViewBuilder<S, St>
where
St: edit_tree_view_state::State,
St::Resource: edit_tree_view_state::IsSet,
St::Branches: edit_tree_view_state::IsSet,
{
pub fn build(self) -> EditTreeView<S> {
EditTreeView {
branches: self._fields.0.unwrap(),
conflict_points: self._fields.1,
has_conflicts: self._fields.2,
main_branch: self._fields.3,
resource: self._fields.4.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> EditTreeView<S> {
EditTreeView {
branches: self._fields.0.unwrap(),
conflict_points: self._fields.1,
has_conflicts: self._fields.2,
main_branch: self._fields.3,
resource: self._fields.4.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod entry_ref_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Entry;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Entry = Unset;
}
pub struct SetEntry<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetEntry<St> {}
impl<St: State> State for SetEntry<St> {
type Entry = Set<members::entry>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct entry(());
}
}
pub struct EntryRefBuilder<S: BosStr, St: entry_ref_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<StrongRef<S>>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> EntryRef<S> {
pub fn new() -> EntryRefBuilder<S, entry_ref_state::Empty> {
EntryRefBuilder::new()
}
}
impl<S: BosStr> EntryRefBuilder<S, entry_ref_state::Empty> {
pub fn new() -> Self {
EntryRefBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> EntryRefBuilder<S, St>
where
St: entry_ref_state::State,
St::Entry: entry_ref_state::IsUnset,
{
pub fn entry(
mut self,
value: impl Into<StrongRef<S>>,
) -> EntryRefBuilder<S, entry_ref_state::SetEntry<St>> {
self._fields.0 = Option::Some(value.into());
EntryRefBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> EntryRefBuilder<S, St>
where
St: entry_ref_state::State,
St::Entry: entry_ref_state::IsSet,
{
pub fn build(self) -> EntryRef<S> {
EntryRef {
entry: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> EntryRef<S> {
EntryRef {
entry: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod notebook_ref_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Notebook;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Notebook = Unset;
}
pub struct SetNotebook<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetNotebook<St> {}
impl<St: State> State for SetNotebook<St> {
type Notebook = Set<members::notebook>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct notebook(());
}
}
pub struct NotebookRefBuilder<S: BosStr, St: notebook_ref_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<StrongRef<S>>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> NotebookRef<S> {
pub fn new() -> NotebookRefBuilder<S, notebook_ref_state::Empty> {
NotebookRefBuilder::new()
}
}
impl<S: BosStr> NotebookRefBuilder<S, notebook_ref_state::Empty> {
pub fn new() -> Self {
NotebookRefBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> NotebookRefBuilder<S, St>
where
St: notebook_ref_state::State,
St::Notebook: notebook_ref_state::IsUnset,
{
pub fn notebook(
mut self,
value: impl Into<StrongRef<S>>,
) -> NotebookRefBuilder<S, notebook_ref_state::SetNotebook<St>> {
self._fields.0 = Option::Some(value.into());
NotebookRefBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> NotebookRefBuilder<S, St>
where
St: notebook_ref_state::State,
St::Notebook: notebook_ref_state::IsSet,
{
pub fn build(self) -> NotebookRef<S> {
NotebookRef {
notebook: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> NotebookRef<S> {
NotebookRef {
notebook: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}