#[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::ident::AtIdentifier;
use jacquard_common::types::string::{AtUri, Nsid, Cid, RecordKey, Rkey};
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::CommitMeta;
use crate::com_atproto::repo::apply_writes;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Create<S: BosStr = DefaultStr> {
pub collection: Nsid<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub rkey: Option<RecordKey<Rkey<S>>>,
pub value: Data<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 CreateResult<S: BosStr = DefaultStr> {
pub cid: Cid<S>,
pub uri: AtUri<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub validation_status: Option<CreateResultValidationStatus<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 CreateResultValidationStatus<S: BosStr = DefaultStr> {
Valid,
Unknown,
Other(S),
}
impl<S: BosStr> CreateResultValidationStatus<S> {
pub fn as_str(&self) -> &str {
match self {
Self::Valid => "valid",
Self::Unknown => "unknown",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"valid" => Self::Valid,
"unknown" => Self::Unknown,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for CreateResultValidationStatus<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for CreateResultValidationStatus<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for CreateResultValidationStatus<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 CreateResultValidationStatus<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 CreateResultValidationStatus<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for CreateResultValidationStatus<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = CreateResultValidationStatus<S::Output>;
fn into_static(self) -> Self::Output {
match self {
CreateResultValidationStatus::Valid => CreateResultValidationStatus::Valid,
CreateResultValidationStatus::Unknown => {
CreateResultValidationStatus::Unknown
}
CreateResultValidationStatus::Other(v) => {
CreateResultValidationStatus::Other(v.into_static())
}
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Delete<S: BosStr = DefaultStr> {
pub collection: Nsid<S>,
pub rkey: RecordKey<Rkey<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, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct DeleteResult<S: BosStr = DefaultStr> {
#[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 ApplyWrites<S: BosStr = DefaultStr> {
pub repo: AtIdentifier<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub swap_commit: Option<Cid<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub validate: Option<bool>,
pub writes: Vec<ApplyWritesWritesItem<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(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum ApplyWritesWritesItem<S: BosStr = DefaultStr> {
#[serde(rename = "com.atproto.repo.applyWrites#create")]
Create(Box<apply_writes::Create<S>>),
#[serde(rename = "com.atproto.repo.applyWrites#update")]
Update(Box<apply_writes::Update<S>>),
#[serde(rename = "com.atproto.repo.applyWrites#delete")]
Delete(Box<apply_writes::Delete<S>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ApplyWritesOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub commit: Option<CommitMeta<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub results: Option<Vec<ApplyWritesOutputResultsItem<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(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum ApplyWritesOutputResultsItem<S: BosStr = DefaultStr> {
#[serde(rename = "com.atproto.repo.applyWrites#createResult")]
CreateResult(Box<apply_writes::CreateResult<S>>),
#[serde(rename = "com.atproto.repo.applyWrites#updateResult")]
UpdateResult(Box<apply_writes::UpdateResult<S>>),
#[serde(rename = "com.atproto.repo.applyWrites#deleteResult")]
DeleteResult(Box<apply_writes::DeleteResult<S>>),
}
#[derive(
Serialize,
Deserialize,
Debug,
Clone,
PartialEq,
Eq,
thiserror::Error,
miette::Diagnostic
)]
#[serde(tag = "error", content = "message")]
pub enum ApplyWritesError {
#[serde(rename = "InvalidSwap")]
InvalidSwap(Option<SmolStr>),
#[serde(untagged)]
Other { error: SmolStr, message: Option<SmolStr> },
}
impl core::fmt::Display for ApplyWritesError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::InvalidSwap(msg) => {
write!(f, "InvalidSwap")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::Other { error, message } => {
write!(f, "{}", error)?;
if let Some(msg) = message {
write!(f, ": {}", msg)?;
}
Ok(())
}
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Update<S: BosStr = DefaultStr> {
pub collection: Nsid<S>,
pub rkey: RecordKey<Rkey<S>>,
pub value: Data<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 UpdateResult<S: BosStr = DefaultStr> {
pub cid: Cid<S>,
pub uri: AtUri<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub validation_status: Option<UpdateResultValidationStatus<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 UpdateResultValidationStatus<S: BosStr = DefaultStr> {
Valid,
Unknown,
Other(S),
}
impl<S: BosStr> UpdateResultValidationStatus<S> {
pub fn as_str(&self) -> &str {
match self {
Self::Valid => "valid",
Self::Unknown => "unknown",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"valid" => Self::Valid,
"unknown" => Self::Unknown,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for UpdateResultValidationStatus<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for UpdateResultValidationStatus<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for UpdateResultValidationStatus<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 UpdateResultValidationStatus<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 UpdateResultValidationStatus<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for UpdateResultValidationStatus<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = UpdateResultValidationStatus<S::Output>;
fn into_static(self) -> Self::Output {
match self {
UpdateResultValidationStatus::Valid => UpdateResultValidationStatus::Valid,
UpdateResultValidationStatus::Unknown => {
UpdateResultValidationStatus::Unknown
}
UpdateResultValidationStatus::Other(v) => {
UpdateResultValidationStatus::Other(v.into_static())
}
}
}
}
impl<S: BosStr> LexiconSchema for Create<S> {
fn nsid() -> &'static str {
"com.atproto.repo.applyWrites"
}
fn def_name() -> &'static str {
"create"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_atproto_repo_applyWrites()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.rkey {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 512usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("rkey"),
max: 512usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for CreateResult<S> {
fn nsid() -> &'static str {
"com.atproto.repo.applyWrites"
}
fn def_name() -> &'static str {
"createResult"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_atproto_repo_applyWrites()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Delete<S> {
fn nsid() -> &'static str {
"com.atproto.repo.applyWrites"
}
fn def_name() -> &'static str {
"delete"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_atproto_repo_applyWrites()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for DeleteResult<S> {
fn nsid() -> &'static str {
"com.atproto.repo.applyWrites"
}
fn def_name() -> &'static str {
"deleteResult"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_atproto_repo_applyWrites()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub struct ApplyWritesResponse;
impl jacquard_common::xrpc::XrpcResp for ApplyWritesResponse {
const NSID: &'static str = "com.atproto.repo.applyWrites";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = ApplyWritesOutput<S>;
type Err = ApplyWritesError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for ApplyWrites<S> {
const NSID: &'static str = "com.atproto.repo.applyWrites";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Response = ApplyWritesResponse;
}
pub struct ApplyWritesRequest;
impl jacquard_common::xrpc::XrpcEndpoint for ApplyWritesRequest {
const PATH: &'static str = "/xrpc/com.atproto.repo.applyWrites";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Request<S: BosStr> = ApplyWrites<S>;
type Response = ApplyWritesResponse;
}
impl<S: BosStr> LexiconSchema for Update<S> {
fn nsid() -> &'static str {
"com.atproto.repo.applyWrites"
}
fn def_name() -> &'static str {
"update"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_atproto_repo_applyWrites()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for UpdateResult<S> {
fn nsid() -> &'static str {
"com.atproto.repo.applyWrites"
}
fn def_name() -> &'static str {
"updateResult"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_atproto_repo_applyWrites()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod create_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;
type Collection;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Value = Unset;
type Collection = 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>;
type Collection = St::Collection;
}
pub struct SetCollection<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCollection<St> {}
impl<St: State> State for SetCollection<St> {
type Value = St::Value;
type Collection = Set<members::collection>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct value(());
pub struct collection(());
}
}
pub struct CreateBuilder<S: BosStr, St: create_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Nsid<S>>, Option<RecordKey<Rkey<S>>>, Option<Data<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Create<S> {
pub fn new() -> CreateBuilder<S, create_state::Empty> {
CreateBuilder::new()
}
}
impl<S: BosStr> CreateBuilder<S, create_state::Empty> {
pub fn new() -> Self {
CreateBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CreateBuilder<S, St>
where
St: create_state::State,
St::Collection: create_state::IsUnset,
{
pub fn collection(
mut self,
value: impl Into<Nsid<S>>,
) -> CreateBuilder<S, create_state::SetCollection<St>> {
self._fields.0 = Option::Some(value.into());
CreateBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: create_state::State> CreateBuilder<S, St> {
pub fn rkey(mut self, value: impl Into<Option<RecordKey<Rkey<S>>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_rkey(mut self, value: Option<RecordKey<Rkey<S>>>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> CreateBuilder<S, St>
where
St: create_state::State,
St::Value: create_state::IsUnset,
{
pub fn value(
mut self,
value: impl Into<Data<S>>,
) -> CreateBuilder<S, create_state::SetValue<St>> {
self._fields.2 = Option::Some(value.into());
CreateBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CreateBuilder<S, St>
where
St: create_state::State,
St::Value: create_state::IsSet,
St::Collection: create_state::IsSet,
{
pub fn build(self) -> Create<S> {
Create {
collection: self._fields.0.unwrap(),
rkey: self._fields.1,
value: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Create<S> {
Create {
collection: self._fields.0.unwrap(),
rkey: self._fields.1,
value: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_com_atproto_repo_applyWrites() -> 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("com.atproto.repo.applyWrites"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("create"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Operation which creates a new record."),
),
required: Some(
vec![
SmolStr::new_static("collection"),
SmolStr::new_static("value")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("collection"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Nsid),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("rkey"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"NOTE: maxLength is redundant with record-key format. Keeping it temporarily to ensure backwards compatibility.",
),
),
format: Some(LexStringFormat::RecordKey),
max_length: Some(512usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("value"),
LexObjectProperty::Unknown(LexUnknown {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createResult"),
LexUserType::Object(LexObject {
required: Some(
vec![SmolStr::new_static("uri"), SmolStr::new_static("cid")],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("cid"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Cid),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("uri"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("validationStatus"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("delete"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Operation which deletes an existing record."),
),
required: Some(
vec![
SmolStr::new_static("collection"),
SmolStr::new_static("rkey")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("collection"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Nsid),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("rkey"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::RecordKey),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("deleteResult"),
LexUserType::Object(LexObject {
required: Some(vec![]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::XrpcProcedure(LexXrpcProcedure {
input: Some(LexXrpcBody {
encoding: CowStr::new_static("application/json"),
schema: Some(
LexXrpcBodySchema::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("repo"), SmolStr::new_static("writes")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("repo"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The handle or DID of the repo (aka, current account).",
),
),
format: Some(LexStringFormat::AtIdentifier),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("swapCommit"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"If provided, the entire operation will fail if the current repo commit CID does not match this value. Used to prevent conflicting repo mutations.",
),
),
format: Some(LexStringFormat::Cid),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("validate"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("writes"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Union(LexRefUnion {
refs: vec![
CowStr::new_static("#create"),
CowStr::new_static("#update"), CowStr::new_static("#delete")
],
closed: Some(true),
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}),
),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("update"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Operation which updates an existing record."),
),
required: Some(
vec![
SmolStr::new_static("collection"),
SmolStr::new_static("rkey"), SmolStr::new_static("value")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("collection"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Nsid),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("rkey"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::RecordKey),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("value"),
LexObjectProperty::Unknown(LexUnknown {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("updateResult"),
LexUserType::Object(LexObject {
required: Some(
vec![SmolStr::new_static("uri"), SmolStr::new_static("cid")],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("cid"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Cid),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("uri"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("validationStatus"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod create_result_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;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Cid = Unset;
type Uri = 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;
}
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>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct cid(());
pub struct uri(());
}
}
pub struct CreateResultBuilder<S: BosStr, St: create_result_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Cid<S>>, Option<AtUri<S>>, Option<CreateResultValidationStatus<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> CreateResult<S> {
pub fn new() -> CreateResultBuilder<S, create_result_state::Empty> {
CreateResultBuilder::new()
}
}
impl<S: BosStr> CreateResultBuilder<S, create_result_state::Empty> {
pub fn new() -> Self {
CreateResultBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CreateResultBuilder<S, St>
where
St: create_result_state::State,
St::Cid: create_result_state::IsUnset,
{
pub fn cid(
mut self,
value: impl Into<Cid<S>>,
) -> CreateResultBuilder<S, create_result_state::SetCid<St>> {
self._fields.0 = Option::Some(value.into());
CreateResultBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CreateResultBuilder<S, St>
where
St: create_result_state::State,
St::Uri: create_result_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<AtUri<S>>,
) -> CreateResultBuilder<S, create_result_state::SetUri<St>> {
self._fields.1 = Option::Some(value.into());
CreateResultBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: create_result_state::State> CreateResultBuilder<S, St> {
pub fn validation_status(
mut self,
value: impl Into<Option<CreateResultValidationStatus<S>>>,
) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_validation_status(
mut self,
value: Option<CreateResultValidationStatus<S>>,
) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St> CreateResultBuilder<S, St>
where
St: create_result_state::State,
St::Cid: create_result_state::IsSet,
St::Uri: create_result_state::IsSet,
{
pub fn build(self) -> CreateResult<S> {
CreateResult {
cid: self._fields.0.unwrap(),
uri: self._fields.1.unwrap(),
validation_status: self._fields.2,
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> CreateResult<S> {
CreateResult {
cid: self._fields.0.unwrap(),
uri: self._fields.1.unwrap(),
validation_status: self._fields.2,
extra_data: Some(extra_data),
}
}
}
pub mod delete_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 Collection;
type Rkey;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Collection = Unset;
type Rkey = Unset;
}
pub struct SetCollection<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCollection<St> {}
impl<St: State> State for SetCollection<St> {
type Collection = Set<members::collection>;
type Rkey = St::Rkey;
}
pub struct SetRkey<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetRkey<St> {}
impl<St: State> State for SetRkey<St> {
type Collection = St::Collection;
type Rkey = Set<members::rkey>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct collection(());
pub struct rkey(());
}
}
pub struct DeleteBuilder<S: BosStr, St: delete_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Nsid<S>>, Option<RecordKey<Rkey<S>>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Delete<S> {
pub fn new() -> DeleteBuilder<S, delete_state::Empty> {
DeleteBuilder::new()
}
}
impl<S: BosStr> DeleteBuilder<S, delete_state::Empty> {
pub fn new() -> Self {
DeleteBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DeleteBuilder<S, St>
where
St: delete_state::State,
St::Collection: delete_state::IsUnset,
{
pub fn collection(
mut self,
value: impl Into<Nsid<S>>,
) -> DeleteBuilder<S, delete_state::SetCollection<St>> {
self._fields.0 = Option::Some(value.into());
DeleteBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DeleteBuilder<S, St>
where
St: delete_state::State,
St::Rkey: delete_state::IsUnset,
{
pub fn rkey(
mut self,
value: impl Into<RecordKey<Rkey<S>>>,
) -> DeleteBuilder<S, delete_state::SetRkey<St>> {
self._fields.1 = Option::Some(value.into());
DeleteBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DeleteBuilder<S, St>
where
St: delete_state::State,
St::Collection: delete_state::IsSet,
St::Rkey: delete_state::IsSet,
{
pub fn build(self) -> Delete<S> {
Delete {
collection: self._fields.0.unwrap(),
rkey: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Delete<S> {
Delete {
collection: self._fields.0.unwrap(),
rkey: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod apply_writes_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 Writes;
type Repo;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Writes = Unset;
type Repo = Unset;
}
pub struct SetWrites<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetWrites<St> {}
impl<St: State> State for SetWrites<St> {
type Writes = Set<members::writes>;
type Repo = St::Repo;
}
pub struct SetRepo<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetRepo<St> {}
impl<St: State> State for SetRepo<St> {
type Writes = St::Writes;
type Repo = Set<members::repo>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct writes(());
pub struct repo(());
}
}
pub struct ApplyWritesBuilder<S: BosStr, St: apply_writes_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<AtIdentifier<S>>,
Option<Cid<S>>,
Option<bool>,
Option<Vec<ApplyWritesWritesItem<S>>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> ApplyWrites<S> {
pub fn new() -> ApplyWritesBuilder<S, apply_writes_state::Empty> {
ApplyWritesBuilder::new()
}
}
impl<S: BosStr> ApplyWritesBuilder<S, apply_writes_state::Empty> {
pub fn new() -> Self {
ApplyWritesBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ApplyWritesBuilder<S, St>
where
St: apply_writes_state::State,
St::Repo: apply_writes_state::IsUnset,
{
pub fn repo(
mut self,
value: impl Into<AtIdentifier<S>>,
) -> ApplyWritesBuilder<S, apply_writes_state::SetRepo<St>> {
self._fields.0 = Option::Some(value.into());
ApplyWritesBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: apply_writes_state::State> ApplyWritesBuilder<S, St> {
pub fn swap_commit(mut self, value: impl Into<Option<Cid<S>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_swap_commit(mut self, value: Option<Cid<S>>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St: apply_writes_state::State> ApplyWritesBuilder<S, St> {
pub fn validate(mut self, value: impl Into<Option<bool>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_validate(mut self, value: Option<bool>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St> ApplyWritesBuilder<S, St>
where
St: apply_writes_state::State,
St::Writes: apply_writes_state::IsUnset,
{
pub fn writes(
mut self,
value: impl Into<Vec<ApplyWritesWritesItem<S>>>,
) -> ApplyWritesBuilder<S, apply_writes_state::SetWrites<St>> {
self._fields.3 = Option::Some(value.into());
ApplyWritesBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ApplyWritesBuilder<S, St>
where
St: apply_writes_state::State,
St::Writes: apply_writes_state::IsSet,
St::Repo: apply_writes_state::IsSet,
{
pub fn build(self) -> ApplyWrites<S> {
ApplyWrites {
repo: self._fields.0.unwrap(),
swap_commit: self._fields.1,
validate: self._fields.2,
writes: self._fields.3.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> ApplyWrites<S> {
ApplyWrites {
repo: self._fields.0.unwrap(),
swap_commit: self._fields.1,
validate: self._fields.2,
writes: self._fields.3.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod update_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 Rkey;
type Value;
type Collection;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Rkey = Unset;
type Value = Unset;
type Collection = Unset;
}
pub struct SetRkey<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetRkey<St> {}
impl<St: State> State for SetRkey<St> {
type Rkey = Set<members::rkey>;
type Value = St::Value;
type Collection = St::Collection;
}
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 Rkey = St::Rkey;
type Value = Set<members::value>;
type Collection = St::Collection;
}
pub struct SetCollection<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCollection<St> {}
impl<St: State> State for SetCollection<St> {
type Rkey = St::Rkey;
type Value = St::Value;
type Collection = Set<members::collection>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct rkey(());
pub struct value(());
pub struct collection(());
}
}
pub struct UpdateBuilder<S: BosStr, St: update_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Nsid<S>>, Option<RecordKey<Rkey<S>>>, Option<Data<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Update<S> {
pub fn new() -> UpdateBuilder<S, update_state::Empty> {
UpdateBuilder::new()
}
}
impl<S: BosStr> UpdateBuilder<S, update_state::Empty> {
pub fn new() -> Self {
UpdateBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> UpdateBuilder<S, St>
where
St: update_state::State,
St::Collection: update_state::IsUnset,
{
pub fn collection(
mut self,
value: impl Into<Nsid<S>>,
) -> UpdateBuilder<S, update_state::SetCollection<St>> {
self._fields.0 = Option::Some(value.into());
UpdateBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> UpdateBuilder<S, St>
where
St: update_state::State,
St::Rkey: update_state::IsUnset,
{
pub fn rkey(
mut self,
value: impl Into<RecordKey<Rkey<S>>>,
) -> UpdateBuilder<S, update_state::SetRkey<St>> {
self._fields.1 = Option::Some(value.into());
UpdateBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> UpdateBuilder<S, St>
where
St: update_state::State,
St::Value: update_state::IsUnset,
{
pub fn value(
mut self,
value: impl Into<Data<S>>,
) -> UpdateBuilder<S, update_state::SetValue<St>> {
self._fields.2 = Option::Some(value.into());
UpdateBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> UpdateBuilder<S, St>
where
St: update_state::State,
St::Rkey: update_state::IsSet,
St::Value: update_state::IsSet,
St::Collection: update_state::IsSet,
{
pub fn build(self) -> Update<S> {
Update {
collection: self._fields.0.unwrap(),
rkey: self._fields.1.unwrap(),
value: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Update<S> {
Update {
collection: self._fields.0.unwrap(),
rkey: self._fields.1.unwrap(),
value: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod update_result_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;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Cid = Unset;
type Uri = 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;
}
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>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct cid(());
pub struct uri(());
}
}
pub struct UpdateResultBuilder<S: BosStr, St: update_result_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Cid<S>>, Option<AtUri<S>>, Option<UpdateResultValidationStatus<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> UpdateResult<S> {
pub fn new() -> UpdateResultBuilder<S, update_result_state::Empty> {
UpdateResultBuilder::new()
}
}
impl<S: BosStr> UpdateResultBuilder<S, update_result_state::Empty> {
pub fn new() -> Self {
UpdateResultBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> UpdateResultBuilder<S, St>
where
St: update_result_state::State,
St::Cid: update_result_state::IsUnset,
{
pub fn cid(
mut self,
value: impl Into<Cid<S>>,
) -> UpdateResultBuilder<S, update_result_state::SetCid<St>> {
self._fields.0 = Option::Some(value.into());
UpdateResultBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> UpdateResultBuilder<S, St>
where
St: update_result_state::State,
St::Uri: update_result_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<AtUri<S>>,
) -> UpdateResultBuilder<S, update_result_state::SetUri<St>> {
self._fields.1 = Option::Some(value.into());
UpdateResultBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: update_result_state::State> UpdateResultBuilder<S, St> {
pub fn validation_status(
mut self,
value: impl Into<Option<UpdateResultValidationStatus<S>>>,
) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_validation_status(
mut self,
value: Option<UpdateResultValidationStatus<S>>,
) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St> UpdateResultBuilder<S, St>
where
St: update_result_state::State,
St::Cid: update_result_state::IsSet,
St::Uri: update_result_state::IsSet,
{
pub fn build(self) -> UpdateResult<S> {
UpdateResult {
cid: self._fields.0.unwrap(),
uri: self._fields.1.unwrap(),
validation_status: self._fields.2,
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> UpdateResult<S> {
UpdateResult {
cid: self._fields.0.unwrap(),
uri: self._fields.1.unwrap(),
validation_status: self._fields.2,
extra_data: Some(extra_data),
}
}
}