Something went wrong. Try again.
atproto made easy crates.io/crates/jacquard
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277// @generated by jacquard-lexicon. DO NOT EDIT.//// Lexicon: dev.tsunagite.difficulty//// This file was automatically generated from Lexicon schemas.// Any manual changes will be overwritten on the next regeneration.
#[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::types::value::Data;use jacquard_common::xrpc::XrpcResp;use jacquard_derive::{IntoStatic, lexicon};use jacquard_lexicon::lexicon::LexiconDoc;use jacquard_lexicon::schema::LexiconSchema;
#[allow(unused_imports)]use jacquard_lexicon::validation::{ConstraintError, ValidationPath};use serde::{Serialize, Deserialize};/// A difficulty slot in a game hosting leaderboards via Tsunagite.
#[lexicon]#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]#[serde(rename_all = "camelCase")]pub struct Difficulty<'a> { ///The hex code color of the difficulty slot. #[serde(skip_serializing_if = "Option::is_none")] #[serde(borrow)] pub color: Option<CowStr<'a>>, ///The human-readable name of the difficulty slot for use in UI. #[serde(borrow)] pub name: Data<'a>,}
/// Typed wrapper for GetRecord response with this collection's record type.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]#[serde(rename_all = "camelCase")]pub struct DifficultyGetRecordOutput<'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: Difficulty<'a>,}
impl<'a> Difficulty<'a> { pub fn uri( uri: impl Into<CowStr<'a>>, ) -> Result<RecordUri<'a, DifficultyRecord>, UriError> { RecordUri::try_from_uri(AtUri::new_cow(uri.into())?) }}
/// Marker type for deserializing records from this collection.
#[derive(Debug, Serialize, Deserialize)]pub struct DifficultyRecord;impl XrpcResp for DifficultyRecord { const NSID: &'static str = "dev.tsunagite.difficulty"; const ENCODING: &'static str = "application/json"; type Output<'de> = DifficultyGetRecordOutput<'de>; type Err<'de> = RecordError<'de>;}
impl From<DifficultyGetRecordOutput<'_>> for Difficulty<'_> { fn from(output: DifficultyGetRecordOutput<'_>) -> Self { use jacquard_common::IntoStatic; output.value.into_static() }}
impl Collection for Difficulty<'_> { const NSID: &'static str = "dev.tsunagite.difficulty"; type Record = DifficultyRecord;}
impl Collection for DifficultyRecord { const NSID: &'static str = "dev.tsunagite.difficulty"; type Record = DifficultyRecord;}
impl<'a> LexiconSchema for Difficulty<'a> { fn nsid() -> &'static str { "dev.tsunagite.difficulty" } fn def_name() -> &'static str { "main" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_dev_tsunagite_difficulty() } fn validate(&self) -> Result<(), ConstraintError> { Ok(()) }}
pub mod difficulty_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; #[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 Name; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Name = Unset; } ///State transition - sets the `name` field to Set pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>); impl<S: State> sealed::Sealed for SetName<S> {} impl<S: State> State for SetName<S> { type Name = Set<members::name>; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `name` field pub struct name(()); }}
/// Builder for constructing an instance of this typepub struct DifficultyBuilder<'a, S: difficulty_state::State> { _state: PhantomData<fn() -> S>, _fields: (Option<CowStr<'a>>, Option<Data<'a>>), _lifetime: PhantomData<&'a ()>,}
impl<'a> Difficulty<'a> { /// Create a new builder for this type pub fn new() -> DifficultyBuilder<'a, difficulty_state::Empty> { DifficultyBuilder::new() }}
impl<'a> DifficultyBuilder<'a, difficulty_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { DifficultyBuilder { _state: PhantomData, _fields: (None, None), _lifetime: PhantomData, } }}
impl<'a, S: difficulty_state::State> DifficultyBuilder<'a, S> { /// Set the `color` field (optional) pub fn color(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self { self._fields.0 = value.into(); self } /// Set the `color` field to an Option value (optional) pub fn maybe_color(mut self, value: Option<CowStr<'a>>) -> Self { self._fields.0 = value; self }}
impl<'a, S> DifficultyBuilder<'a, S>where S: difficulty_state::State, S::Name: difficulty_state::IsUnset,{ /// Set the `name` field (required) pub fn name( mut self, value: impl Into<Data<'a>>, ) -> DifficultyBuilder<'a, difficulty_state::SetName<S>> { self._fields.1 = Option::Some(value.into()); DifficultyBuilder { _state: PhantomData, _fields: self._fields, _lifetime: PhantomData, } }}
impl<'a, S> DifficultyBuilder<'a, S>where S: difficulty_state::State, S::Name: difficulty_state::IsSet,{ /// Build the final struct pub fn build(self) -> Difficulty<'a> { Difficulty { color: self._fields.0, name: self._fields.1.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data pub fn build_with_data( self, extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>, ) -> Difficulty<'a> { Difficulty { color: self._fields.0, name: self._fields.1.unwrap(), extra_data: Some(extra_data), } }}
fn lexicon_doc_dev_tsunagite_difficulty() -> 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("dev.tsunagite.difficulty"), defs: { let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("main"), LexUserType::Record(LexRecord { description: Some( CowStr::new_static( "A difficulty slot in a game hosting leaderboards via Tsunagite.", ), ), key: Some(CowStr::new_static("any")), record: LexRecordRecord::Object(LexObject { required: Some(vec![SmolStr::new_static("name")]), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("color"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static( "The hex code color of the difficulty slot.", ), ), ..Default::default() }), ); map.insert( SmolStr::new_static("name"), LexObjectProperty::Ref(LexRef { r#ref: CowStr::new_static("dev.tsunagite.translatable"), ..Default::default() }), ); map }, ..Default::default() }), ..Default::default() }), ); map }, ..Default::default() }}