// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: blue.2048.defs // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. //! Generated bindings for the `blue..2048` Lexicon namespace/module. pub mod game; pub mod key; pub mod player; pub mod verification; #[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::string::Datetime; use jacquard_common::types::value::Data; use jacquard_derive::IntoStatic; use jacquard_lexicon::lexicon::LexiconDoc; use jacquard_lexicon::schema::LexiconSchema; #[allow(unused_imports)] use jacquard_lexicon::validation::{ConstraintError, ValidationPath}; use serde::{Deserialize, Serialize}; /// The sync status for a record used to help sync between your ATProto record and local record. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] #[serde( rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr") )] pub struct SyncStatus { pub created_at: Datetime, /// A XXH3 hash of the record to tell if anything has changed pub hash: S, /// A flag to know if it has been synced with the AT repo. Used mostly client side to filter what records need syncing Defaults to `false`. #[serde(default = "_default_sync_status_synced_with_at_repo")] pub synced_with_at_repo: bool, pub updated_at: Datetime, #[serde( flatten, default, deserialize_with = "deserialize_sync_status_extra_data", skip_serializing_if = "Option::is_none" )] pub extra_data: Option>>, } impl LexiconSchema for SyncStatus { fn nsid() -> &'static str { "blue.2048.defs" } fn def_name() -> &'static str { "syncStatus" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_blue_2048_defs() } fn validate(&self) -> Result<(), ConstraintError> { Ok(()) } } fn deserialize_sync_status_extra_data<'de, S, D>( deserializer: D, ) -> Result>>, D::Error> where S: BosStr + serde::Deserialize<'de>, D: serde::Deserializer<'de>, { let data = >> as serde::Deserialize<'de>>::deserialize(deserializer)?; Ok(data.filter(|extra_data| !extra_data.is_empty())) } fn _default_sync_status_synced_with_at_repo() -> bool { false } pub mod sync_status_state { pub use crate::builder_types::{IsSet, IsUnset, Set, Unset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type CreatedAt; type Hash; type SyncedWithAtRepo; type UpdatedAt; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type CreatedAt = Unset; type Hash = Unset; type SyncedWithAtRepo = Unset; type UpdatedAt = Unset; } ///State transition - sets the `created_at` field to Set pub struct SetCreatedAt(PhantomData St>); impl sealed::Sealed for SetCreatedAt {} impl State for SetCreatedAt { type CreatedAt = Set; type Hash = St::Hash; type SyncedWithAtRepo = St::SyncedWithAtRepo; type UpdatedAt = St::UpdatedAt; } ///State transition - sets the `hash` field to Set pub struct SetHash(PhantomData St>); impl sealed::Sealed for SetHash {} impl State for SetHash { type CreatedAt = St::CreatedAt; type Hash = Set; type SyncedWithAtRepo = St::SyncedWithAtRepo; type UpdatedAt = St::UpdatedAt; } ///State transition - sets the `synced_with_at_repo` field to Set pub struct SetSyncedWithAtRepo(PhantomData St>); impl sealed::Sealed for SetSyncedWithAtRepo {} impl State for SetSyncedWithAtRepo { type CreatedAt = St::CreatedAt; type Hash = St::Hash; type SyncedWithAtRepo = Set; type UpdatedAt = St::UpdatedAt; } ///State transition - sets the `updated_at` field to Set pub struct SetUpdatedAt(PhantomData St>); impl sealed::Sealed for SetUpdatedAt {} impl State for SetUpdatedAt { type CreatedAt = St::CreatedAt; type Hash = St::Hash; type SyncedWithAtRepo = St::SyncedWithAtRepo; type UpdatedAt = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `created_at` field pub struct created_at(()); ///Marker type for the `hash` field pub struct hash(()); ///Marker type for the `synced_with_at_repo` field pub struct synced_with_at_repo(()); ///Marker type for the `updated_at` field pub struct updated_at(()); } } /// Builder for constructing an instance of this type. pub struct SyncStatusBuilder { _state: PhantomData St>, _fields: (Option, Option, Option, Option), _type: PhantomData S>, } impl SyncStatus { /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed pub fn new() -> SyncStatusBuilder { SyncStatusBuilder::new() } } impl SyncStatus { /// Create a new builder for this type pub fn builder() -> SyncStatusBuilder { SyncStatusBuilder::builder() } } impl SyncStatusBuilder { /// Create a new builder with all fields unset, using the default string type, if needed pub fn new() -> Self { SyncStatusBuilder { _state: PhantomData, _fields: (None, None, None, None), _type: PhantomData, } } } impl SyncStatusBuilder { /// Create a new builder with all fields unset pub fn builder() -> Self { SyncStatusBuilder { _state: PhantomData, _fields: (None, None, None, None), _type: PhantomData, } } } impl SyncStatusBuilder where St: sync_status_state::State, St::CreatedAt: sync_status_state::IsUnset, { /// Set the `createdAt` field (required) pub fn created_at( mut self, value: impl Into, ) -> SyncStatusBuilder, S> { self._fields.0 = Option::Some(value.into()); SyncStatusBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl SyncStatusBuilder where St: sync_status_state::State, St::Hash: sync_status_state::IsUnset, { /// Set the `hash` field (required) pub fn hash( mut self, value: impl Into, ) -> SyncStatusBuilder, S> { self._fields.1 = Option::Some(value.into()); SyncStatusBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl SyncStatusBuilder where St: sync_status_state::State, St::SyncedWithAtRepo: sync_status_state::IsUnset, { /// Set the `syncedWithATRepo` field (required) pub fn synced_with_at_repo( mut self, value: impl Into, ) -> SyncStatusBuilder, S> { self._fields.2 = Option::Some(value.into()); SyncStatusBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl SyncStatusBuilder where St: sync_status_state::State, St::UpdatedAt: sync_status_state::IsUnset, { /// Set the `updatedAt` field (required) pub fn updated_at( mut self, value: impl Into, ) -> SyncStatusBuilder, S> { self._fields.3 = Option::Some(value.into()); SyncStatusBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl SyncStatusBuilder where St: sync_status_state::State, St::CreatedAt: sync_status_state::IsSet, St::Hash: sync_status_state::IsSet, St::SyncedWithAtRepo: sync_status_state::IsSet, St::UpdatedAt: sync_status_state::IsSet, { /// Build the final struct. pub fn build(self) -> SyncStatus { SyncStatus { created_at: self._fields.0.unwrap(), hash: self._fields.1.unwrap(), synced_with_at_repo: self._fields.2.unwrap(), updated_at: self._fields.3.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data. pub fn build_with_data(self, extra_data: BTreeMap>) -> SyncStatus { SyncStatus { created_at: self._fields.0.unwrap(), hash: self._fields.1.unwrap(), synced_with_at_repo: self._fields.2.unwrap(), updated_at: self._fields.3.unwrap(), extra_data: Some(extra_data), } } } fn lexicon_doc_blue_2048_defs() -> 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("blue.2048.defs"), defs: { let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("syncStatus"), LexUserType::Object(LexObject { description: Some( CowStr::new_static( "The sync status for a record used to help sync between your ATProto record and local record.", ), ), required: Some( vec![ SmolStr::new_static("hash"), SmolStr::new_static("updatedAt"), SmolStr::new_static("createdAt"), SmolStr::new_static("syncedWithATRepo") ], ), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("createdAt"), LexObjectProperty::String(LexString { format: Some(LexStringFormat::Datetime), ..Default::default() }), ); map.insert( SmolStr::new_static("hash"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static( "A XXH3 hash of the record to tell if anything has changed", ), ), ..Default::default() }), ); map.insert( SmolStr::new_static("syncedWithATRepo"), LexObjectProperty::Boolean(LexBoolean { ..Default::default() }), ); map.insert( SmolStr::new_static("updatedAt"), LexObjectProperty::String(LexString { format: Some(LexStringFormat::Datetime), ..Default::default() }), ); map }, ..Default::default() }), ); map }, ..Default::default() } }