#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon, 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::sh_weaver::edit::cursor;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ContainerId<'a> {
#[serde(borrow)]
pub value: ContainerIdValue<'a>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "'de: 'a"))]
pub enum ContainerIdValue<'a> {
#[serde(rename = "sh.weaver.edit.cursor#normalContainerId")]
NormalContainerId(Box<cursor::NormalContainerId<'a>>),
#[serde(rename = "sh.weaver.edit.cursor#rootContainerId")]
RootContainerId(Box<cursor::RootContainerId<'a>>),
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct CursorSide<'a> {
pub value: i64,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Id<'a> {
pub counter: i64,
pub peer: i64,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", rename = "sh.weaver.edit.cursor", tag = "$type")]
pub struct Cursor<'a> {
#[serde(borrow)]
pub container: cursor::ContainerId<'a>,
#[serde(borrow)]
pub id: cursor::Id<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub side: Option<cursor::CursorSide<'a>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct CursorGetRecordOutput<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cid: Option<Cid<'a>>,
#[serde(borrow)]
pub uri: AtUri<'a>,
#[serde(borrow)]
pub value: Cursor<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct NormalContainerId<'a> {
#[serde(borrow)]
pub container_type: CowStr<'a>,
pub counter: i64,
pub peer: i64,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct RootContainerId<'a> {
#[serde(borrow)]
pub container_type: CowStr<'a>,
#[serde(borrow)]
pub name: CowStr<'a>,
}
impl<'a> Cursor<'a> {
pub fn uri(
uri: impl Into<CowStr<'a>>,
) -> Result<RecordUri<'a, CursorRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
}
}
impl<'a> LexiconSchema for ContainerId<'a> {
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<'a> LexiconSchema for CursorSide<'a> {
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<'a> LexiconSchema for Id<'a> {
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<'de> = CursorGetRecordOutput<'de>;
type Err<'de> = RecordError<'de>;
}
impl From<CursorGetRecordOutput<'_>> for Cursor<'_> {
fn from(output: CursorGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl Collection for Cursor<'_> {
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<'a> LexiconSchema for Cursor<'a> {
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<'a> LexiconSchema for NormalContainerId<'a> {
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<'a> LexiconSchema for RootContainerId<'a> {
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::{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<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetValue<S> {}
impl<S: State> State for SetValue<S> {
type Value = Set<members::value>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct value(());
}
}
pub struct ContainerIdBuilder<'a, S: container_id_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<ContainerIdValue<'a>>,),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> ContainerId<'a> {
pub fn new() -> ContainerIdBuilder<'a, container_id_state::Empty> {
ContainerIdBuilder::new()
}
}
impl<'a> ContainerIdBuilder<'a, container_id_state::Empty> {
pub fn new() -> Self {
ContainerIdBuilder {
_state: PhantomData,
_fields: (None,),
_lifetime: PhantomData,
}
}
}
impl<'a, S> ContainerIdBuilder<'a, S>
where
S: container_id_state::State,
S::Value: container_id_state::IsUnset,
{
pub fn value(
mut self,
value: impl Into<ContainerIdValue<'a>>,
) -> ContainerIdBuilder<'a, container_id_state::SetValue<S>> {
self._fields.0 = Option::Some(value.into());
ContainerIdBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ContainerIdBuilder<'a, S>
where
S: container_id_state::State,
S::Value: container_id_state::IsSet,
{
pub fn build(self) -> ContainerId<'a> {
ContainerId {
value: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> ContainerId<'a> {
ContainerId {
value: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_sh_weaver_edit_cursor() -> 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.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::{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<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetValue<S> {}
impl<S: State> State for SetValue<S> {
type Value = Set<members::value>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct value(());
}
}
pub struct CursorSideBuilder<'a, S: cursor_side_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<i64>,),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> CursorSide<'a> {
pub fn new() -> CursorSideBuilder<'a, cursor_side_state::Empty> {
CursorSideBuilder::new()
}
}
impl<'a> CursorSideBuilder<'a, cursor_side_state::Empty> {
pub fn new() -> Self {
CursorSideBuilder {
_state: PhantomData,
_fields: (None,),
_lifetime: PhantomData,
}
}
}
impl<'a, S> CursorSideBuilder<'a, S>
where
S: cursor_side_state::State,
S::Value: cursor_side_state::IsUnset,
{
pub fn value(
mut self,
value: impl Into<i64>,
) -> CursorSideBuilder<'a, cursor_side_state::SetValue<S>> {
self._fields.0 = Option::Some(value.into());
CursorSideBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> CursorSideBuilder<'a, S>
where
S: cursor_side_state::State,
S::Value: cursor_side_state::IsSet,
{
pub fn build(self) -> CursorSide<'a> {
CursorSide {
value: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> CursorSide<'a> {
CursorSide {
value: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod id_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 Peer;
type Counter;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Peer = Unset;
type Counter = Unset;
}
pub struct SetPeer<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetPeer<S> {}
impl<S: State> State for SetPeer<S> {
type Peer = Set<members::peer>;
type Counter = S::Counter;
}
pub struct SetCounter<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCounter<S> {}
impl<S: State> State for SetCounter<S> {
type Peer = S::Peer;
type Counter = Set<members::counter>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct peer(());
pub struct counter(());
}
}
pub struct IdBuilder<'a, S: id_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<i64>, Option<i64>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Id<'a> {
pub fn new() -> IdBuilder<'a, id_state::Empty> {
IdBuilder::new()
}
}
impl<'a> IdBuilder<'a, id_state::Empty> {
pub fn new() -> Self {
IdBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> IdBuilder<'a, S>
where
S: id_state::State,
S::Counter: id_state::IsUnset,
{
pub fn counter(
mut self,
value: impl Into<i64>,
) -> IdBuilder<'a, id_state::SetCounter<S>> {
self._fields.0 = Option::Some(value.into());
IdBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> IdBuilder<'a, S>
where
S: id_state::State,
S::Peer: id_state::IsUnset,
{
pub fn peer(mut self, value: impl Into<i64>) -> IdBuilder<'a, id_state::SetPeer<S>> {
self._fields.1 = Option::Some(value.into());
IdBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> IdBuilder<'a, S>
where
S: id_state::State,
S::Peer: id_state::IsSet,
S::Counter: id_state::IsSet,
{
pub fn build(self) -> Id<'a> {
Id {
counter: self._fields.0.unwrap(),
peer: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Id<'a> {
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::{Set, Unset, IsSet, IsUnset};
#[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<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetContainer<S> {}
impl<S: State> State for SetContainer<S> {
type Container = Set<members::container>;
type Id = S::Id;
}
pub struct SetId<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetId<S> {}
impl<S: State> State for SetId<S> {
type Container = S::Container;
type Id = Set<members::id>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct container(());
pub struct id(());
}
}
pub struct CursorBuilder<'a, S: cursor_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<cursor::ContainerId<'a>>,
Option<cursor::Id<'a>>,
Option<cursor::CursorSide<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Cursor<'a> {
pub fn new() -> CursorBuilder<'a, cursor_state::Empty> {
CursorBuilder::new()
}
}
impl<'a> CursorBuilder<'a, cursor_state::Empty> {
pub fn new() -> Self {
CursorBuilder {
_state: PhantomData,
_fields: (None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> CursorBuilder<'a, S>
where
S: cursor_state::State,
S::Container: cursor_state::IsUnset,
{
pub fn container(
mut self,
value: impl Into<cursor::ContainerId<'a>>,
) -> CursorBuilder<'a, cursor_state::SetContainer<S>> {
self._fields.0 = Option::Some(value.into());
CursorBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> CursorBuilder<'a, S>
where
S: cursor_state::State,
S::Id: cursor_state::IsUnset,
{
pub fn id(
mut self,
value: impl Into<cursor::Id<'a>>,
) -> CursorBuilder<'a, cursor_state::SetId<S>> {
self._fields.1 = Option::Some(value.into());
CursorBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: cursor_state::State> CursorBuilder<'a, S> {
pub fn side(mut self, value: impl Into<Option<cursor::CursorSide<'a>>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_side(mut self, value: Option<cursor::CursorSide<'a>>) -> Self {
self._fields.2 = value;
self
}
}
impl<'a, S> CursorBuilder<'a, S>
where
S: cursor_state::State,
S::Container: cursor_state::IsSet,
S::Id: cursor_state::IsSet,
{
pub fn build(self) -> Cursor<'a> {
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<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Cursor<'a> {
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::{Set, Unset, IsSet, IsUnset};
#[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<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetContainerType<S> {}
impl<S: State> State for SetContainerType<S> {
type ContainerType = Set<members::container_type>;
type Counter = S::Counter;
type Peer = S::Peer;
}
pub struct SetCounter<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCounter<S> {}
impl<S: State> State for SetCounter<S> {
type ContainerType = S::ContainerType;
type Counter = Set<members::counter>;
type Peer = S::Peer;
}
pub struct SetPeer<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetPeer<S> {}
impl<S: State> State for SetPeer<S> {
type ContainerType = S::ContainerType;
type Counter = S::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<'a, S: normal_container_id_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<CowStr<'a>>, Option<i64>, Option<i64>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> NormalContainerId<'a> {
pub fn new() -> NormalContainerIdBuilder<'a, normal_container_id_state::Empty> {
NormalContainerIdBuilder::new()
}
}
impl<'a> NormalContainerIdBuilder<'a, normal_container_id_state::Empty> {
pub fn new() -> Self {
NormalContainerIdBuilder {
_state: PhantomData,
_fields: (None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> NormalContainerIdBuilder<'a, S>
where
S: normal_container_id_state::State,
S::ContainerType: normal_container_id_state::IsUnset,
{
pub fn container_type(
mut self,
value: impl Into<CowStr<'a>>,
) -> NormalContainerIdBuilder<'a, normal_container_id_state::SetContainerType<S>> {
self._fields.0 = Option::Some(value.into());
NormalContainerIdBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> NormalContainerIdBuilder<'a, S>
where
S: normal_container_id_state::State,
S::Counter: normal_container_id_state::IsUnset,
{
pub fn counter(
mut self,
value: impl Into<i64>,
) -> NormalContainerIdBuilder<'a, normal_container_id_state::SetCounter<S>> {
self._fields.1 = Option::Some(value.into());
NormalContainerIdBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> NormalContainerIdBuilder<'a, S>
where
S: normal_container_id_state::State,
S::Peer: normal_container_id_state::IsUnset,
{
pub fn peer(
mut self,
value: impl Into<i64>,
) -> NormalContainerIdBuilder<'a, normal_container_id_state::SetPeer<S>> {
self._fields.2 = Option::Some(value.into());
NormalContainerIdBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> NormalContainerIdBuilder<'a, S>
where
S: normal_container_id_state::State,
S::ContainerType: normal_container_id_state::IsSet,
S::Counter: normal_container_id_state::IsSet,
S::Peer: normal_container_id_state::IsSet,
{
pub fn build(self) -> NormalContainerId<'a> {
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<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> NormalContainerId<'a> {
NormalContainerId {
container_type: self._fields.0.unwrap(),
counter: self._fields.1.unwrap(),
peer: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}