#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::sh_weaver::edit::cursor;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct ContainerId<S: BosStr = DefaultStr> {
pub value: ContainerIdValue<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 ContainerIdValue<S: BosStr = DefaultStr> {
#[serde(rename = "sh.weaver.edit.cursor#normalContainerId")]
NormalContainerId(Box<cursor::NormalContainerId<S>>),
#[serde(rename = "sh.weaver.edit.cursor#rootContainerId")]
RootContainerId(Box<cursor::RootContainerId<S>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct CursorSide<S: BosStr = DefaultStr> {
pub value: i64,
#[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 Id<S: BosStr = DefaultStr> {
pub counter: i64,
pub peer: i64,
#[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",
rename = "sh.weaver.edit.cursor",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Cursor<S: BosStr = DefaultStr> {
pub container: cursor::ContainerId<S>,
pub id: cursor::Id<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub side: Option<cursor::CursorSide<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")]
pub struct CursorGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Cursor<S>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct NormalContainerId<S: BosStr = DefaultStr> {
pub container_type: S,
pub counter: i64,
pub peer: i64,
#[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, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct RootContainerId<S: BosStr = DefaultStr> {
pub container_type: S,
pub name: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> Cursor<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, CursorRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
impl<S: BosStr> LexiconSchema for ContainerId<S> {
fn nsid() -> &'static str {
"sh.weaver.edit.cursor"
}
fn def_name() -> &'static str {
"containerId"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_weaver_edit_cursor()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for CursorSide<S> {
fn nsid() -> &'static str {
"sh.weaver.edit.cursor"
}
fn def_name() -> &'static str {
"cursorSide"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_weaver_edit_cursor()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Id<S> {
fn nsid() -> &'static str {
"sh.weaver.edit.cursor"
}
fn def_name() -> &'static str {
"id"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_weaver_edit_cursor()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct CursorRecord;
impl XrpcResp for CursorRecord {
const NSID: &'static str = "sh.weaver.edit.cursor";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = CursorGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<CursorGetRecordOutput<S>> for Cursor<S> {
fn from(output: CursorGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Cursor<S> {
const NSID: &'static str = "sh.weaver.edit.cursor";
type Record = CursorRecord;
}
impl Collection for CursorRecord {
const NSID: &'static str = "sh.weaver.edit.cursor";
type Record = CursorRecord;
}
impl<S: BosStr> LexiconSchema for Cursor<S> {
fn nsid() -> &'static str {
"sh.weaver.edit.cursor"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_weaver_edit_cursor()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for NormalContainerId<S> {
fn nsid() -> &'static str {
"sh.weaver.edit.cursor"
}
fn def_name() -> &'static str {
"normalContainerId"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_weaver_edit_cursor()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for RootContainerId<S> {
fn nsid() -> &'static str {
"sh.weaver.edit.cursor"
}
fn def_name() -> &'static str {
"rootContainerId"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_weaver_edit_cursor()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod container_id_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[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 ContainerIdBuilder<S: BosStr, St: container_id_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<ContainerIdValue<S>>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> ContainerId<S> {
pub fn new() -> ContainerIdBuilder<S, container_id_state::Empty> {
ContainerIdBuilder::new()
}
}
impl<S: BosStr> ContainerIdBuilder<S, container_id_state::Empty> {
pub fn new() -> Self {
ContainerIdBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ContainerIdBuilder<S, St>
where
St: container_id_state::State,
St::Value: container_id_state::IsUnset,
{
pub fn value(
mut self,
value: impl Into<ContainerIdValue<S>>,
) -> ContainerIdBuilder<S, container_id_state::SetValue<St>> {
self._fields.0 = Option::Some(value.into());
ContainerIdBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ContainerIdBuilder<S, St>
where
St: container_id_state::State,
St::Value: container_id_state::IsSet,
{
pub fn build(self) -> ContainerId<S> {
ContainerId {
value: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> ContainerId<S> {
ContainerId {
value: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_sh_weaver_edit_cursor() -> LexiconDoc<'static> {
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("sh.weaver.edit.cursor"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("containerId"),
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("#normalContainerId"),
CowStr::new_static("#rootContainerId"),
],
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("cursorSide"),
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::Integer(LexInteger {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("id"),
LexUserType::Object(LexObject {
required: Some(vec![
SmolStr::new_static("peer"),
SmolStr::new_static("counter"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("counter"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("peer"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(CowStr::new_static("An edit record for a notebook.")),
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(vec![
SmolStr::new_static("container"),
SmolStr::new_static("id"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("container"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#containerId"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("id"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#id"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("side"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#cursorSide"),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("normalContainerId"),
LexUserType::Object(LexObject {
required: Some(vec![
SmolStr::new_static("peer"),
SmolStr::new_static("counter"),
SmolStr::new_static("container_type"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("container_type"),
LexObjectProperty::String(LexString {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("counter"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("peer"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("rootContainerId"),
LexUserType::Object(LexObject {
required: Some(vec![
SmolStr::new_static("name"),
SmolStr::new_static("container_type"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("container_type"),
LexObjectProperty::String(LexString {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod cursor_side_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[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 CursorSideBuilder<S: BosStr, St: cursor_side_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<i64>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> CursorSide<S> {
pub fn new() -> CursorSideBuilder<S, cursor_side_state::Empty> {
CursorSideBuilder::new()
}
}
impl<S: BosStr> CursorSideBuilder<S, cursor_side_state::Empty> {
pub fn new() -> Self {
CursorSideBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CursorSideBuilder<S, St>
where
St: cursor_side_state::State,
St::Value: cursor_side_state::IsUnset,
{
pub fn value(
mut self,
value: impl Into<i64>,
) -> CursorSideBuilder<S, cursor_side_state::SetValue<St>> {
self._fields.0 = Option::Some(value.into());
CursorSideBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CursorSideBuilder<S, St>
where
St: cursor_side_state::State,
St::Value: cursor_side_state::IsSet,
{
pub fn build(self) -> CursorSide<S> {
CursorSide {
value: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> CursorSide<S> {
CursorSide {
value: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod id_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Peer;
type Counter;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Peer = Unset;
type Counter = Unset;
}
pub struct SetPeer<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetPeer<St> {}
impl<St: State> State for SetPeer<St> {
type Peer = Set<members::peer>;
type Counter = St::Counter;
}
pub struct SetCounter<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCounter<St> {}
impl<St: State> State for SetCounter<St> {
type Peer = St::Peer;
type Counter = Set<members::counter>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct peer(());
pub struct counter(());
}
}
pub struct IdBuilder<S: BosStr, St: id_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<i64>, Option<i64>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Id<S> {
pub fn new() -> IdBuilder<S, id_state::Empty> {
IdBuilder::new()
}
}
impl<S: BosStr> IdBuilder<S, id_state::Empty> {
pub fn new() -> Self {
IdBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> IdBuilder<S, St>
where
St: id_state::State,
St::Counter: id_state::IsUnset,
{
pub fn counter(mut self, value: impl Into<i64>) -> IdBuilder<S, id_state::SetCounter<St>> {
self._fields.0 = Option::Some(value.into());
IdBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> IdBuilder<S, St>
where
St: id_state::State,
St::Peer: id_state::IsUnset,
{
pub fn peer(mut self, value: impl Into<i64>) -> IdBuilder<S, id_state::SetPeer<St>> {
self._fields.1 = Option::Some(value.into());
IdBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> IdBuilder<S, St>
where
St: id_state::State,
St::Peer: id_state::IsSet,
St::Counter: id_state::IsSet,
{
pub fn build(self) -> Id<S> {
Id {
counter: self._fields.0.unwrap(),
peer: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Id<S> {
Id {
counter: self._fields.0.unwrap(),
peer: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod cursor_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Container;
type Id;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Container = Unset;
type Id = Unset;
}
pub struct SetContainer<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetContainer<St> {}
impl<St: State> State for SetContainer<St> {
type Container = Set<members::container>;
type Id = St::Id;
}
pub struct SetId<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetId<St> {}
impl<St: State> State for SetId<St> {
type Container = St::Container;
type Id = Set<members::id>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct container(());
pub struct id(());
}
}
pub struct CursorBuilder<S: BosStr, St: cursor_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<cursor::ContainerId<S>>,
Option<cursor::Id<S>>,
Option<cursor::CursorSide<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Cursor<S> {
pub fn new() -> CursorBuilder<S, cursor_state::Empty> {
CursorBuilder::new()
}
}
impl<S: BosStr> CursorBuilder<S, cursor_state::Empty> {
pub fn new() -> Self {
CursorBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CursorBuilder<S, St>
where
St: cursor_state::State,
St::Container: cursor_state::IsUnset,
{
pub fn container(
mut self,
value: impl Into<cursor::ContainerId<S>>,
) -> CursorBuilder<S, cursor_state::SetContainer<St>> {
self._fields.0 = Option::Some(value.into());
CursorBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CursorBuilder<S, St>
where
St: cursor_state::State,
St::Id: cursor_state::IsUnset,
{
pub fn id(
mut self,
value: impl Into<cursor::Id<S>>,
) -> CursorBuilder<S, cursor_state::SetId<St>> {
self._fields.1 = Option::Some(value.into());
CursorBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: cursor_state::State> CursorBuilder<S, St> {
pub fn side(mut self, value: impl Into<Option<cursor::CursorSide<S>>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_side(mut self, value: Option<cursor::CursorSide<S>>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St> CursorBuilder<S, St>
where
St: cursor_state::State,
St::Container: cursor_state::IsSet,
St::Id: cursor_state::IsSet,
{
pub fn build(self) -> Cursor<S> {
Cursor {
container: self._fields.0.unwrap(),
id: self._fields.1.unwrap(),
side: self._fields.2,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Cursor<S> {
Cursor {
container: self._fields.0.unwrap(),
id: self._fields.1.unwrap(),
side: self._fields.2,
extra_data: Some(extra_data),
}
}
}
pub mod normal_container_id_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type ContainerType;
type Counter;
type Peer;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type ContainerType = Unset;
type Counter = Unset;
type Peer = Unset;
}
pub struct SetContainerType<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetContainerType<St> {}
impl<St: State> State for SetContainerType<St> {
type ContainerType = Set<members::container_type>;
type Counter = St::Counter;
type Peer = St::Peer;
}
pub struct SetCounter<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCounter<St> {}
impl<St: State> State for SetCounter<St> {
type ContainerType = St::ContainerType;
type Counter = Set<members::counter>;
type Peer = St::Peer;
}
pub struct SetPeer<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetPeer<St> {}
impl<St: State> State for SetPeer<St> {
type ContainerType = St::ContainerType;
type Counter = St::Counter;
type Peer = Set<members::peer>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct container_type(());
pub struct counter(());
pub struct peer(());
}
}
pub struct NormalContainerIdBuilder<S: BosStr, St: normal_container_id_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<S>, Option<i64>, Option<i64>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> NormalContainerId<S> {
pub fn new() -> NormalContainerIdBuilder<S, normal_container_id_state::Empty> {
NormalContainerIdBuilder::new()
}
}
impl<S: BosStr> NormalContainerIdBuilder<S, normal_container_id_state::Empty> {
pub fn new() -> Self {
NormalContainerIdBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> NormalContainerIdBuilder<S, St>
where
St: normal_container_id_state::State,
St::ContainerType: normal_container_id_state::IsUnset,
{
pub fn container_type(
mut self,
value: impl Into<S>,
) -> NormalContainerIdBuilder<S, normal_container_id_state::SetContainerType<St>> {
self._fields.0 = Option::Some(value.into());
NormalContainerIdBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> NormalContainerIdBuilder<S, St>
where
St: normal_container_id_state::State,
St::Counter: normal_container_id_state::IsUnset,
{
pub fn counter(
mut self,
value: impl Into<i64>,
) -> NormalContainerIdBuilder<S, normal_container_id_state::SetCounter<St>> {
self._fields.1 = Option::Some(value.into());
NormalContainerIdBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> NormalContainerIdBuilder<S, St>
where
St: normal_container_id_state::State,
St::Peer: normal_container_id_state::IsUnset,
{
pub fn peer(
mut self,
value: impl Into<i64>,
) -> NormalContainerIdBuilder<S, normal_container_id_state::SetPeer<St>> {
self._fields.2 = Option::Some(value.into());
NormalContainerIdBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> NormalContainerIdBuilder<S, St>
where
St: normal_container_id_state::State,
St::ContainerType: normal_container_id_state::IsSet,
St::Counter: normal_container_id_state::IsSet,
St::Peer: normal_container_id_state::IsSet,
{
pub fn build(self) -> NormalContainerId<S> {
NormalContainerId {
container_type: self._fields.0.unwrap(),
counter: self._fields.1.unwrap(),
peer: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> NormalContainerId<S> {
NormalContainerId {
container_type: self._fields.0.unwrap(),
counter: self._fields.1.unwrap(),
peer: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}