#[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::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime};
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};
use crate::com_atproto::repo::strong_ref::StrongRef;
use crate::games_gamesgamesgamesgames::CompanyRole;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
rename = "games.gamesgamesgamesgames.org.credit",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Credit<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub created_at: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<S>,
pub game: StrongRef<S>,
pub org: StrongRef<S>,
pub roles: Vec<CompanyRole<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 CreditGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Credit<S>,
}
impl<S: BosStr> Credit<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, CreditRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct CreditRecord;
impl XrpcResp for CreditRecord {
const NSID: &'static str = "games.gamesgamesgamesgames.org.credit";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = CreditGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<CreditGetRecordOutput<S>> for Credit<S> {
fn from(output: CreditGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Credit<S> {
const NSID: &'static str = "games.gamesgamesgamesgames.org.credit";
type Record = CreditRecord;
}
impl Collection for CreditRecord {
const NSID: &'static str = "games.gamesgamesgamesgames.org.credit";
type Record = CreditRecord;
}
impl<S: BosStr> LexiconSchema for Credit<S> {
fn nsid() -> &'static str {
"games.gamesgamesgamesgames.org.credit"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_games_gamesgamesgamesgames_org_credit()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.display_name {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 640usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("display_name"),
max: 640usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
pub mod credit_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 Roles;
type Game;
type Org;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Roles = Unset;
type Game = Unset;
type Org = Unset;
}
pub struct SetRoles<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetRoles<St> {}
impl<St: State> State for SetRoles<St> {
type Roles = Set<members::roles>;
type Game = St::Game;
type Org = St::Org;
}
pub struct SetGame<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetGame<St> {}
impl<St: State> State for SetGame<St> {
type Roles = St::Roles;
type Game = Set<members::game>;
type Org = St::Org;
}
pub struct SetOrg<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetOrg<St> {}
impl<St: State> State for SetOrg<St> {
type Roles = St::Roles;
type Game = St::Game;
type Org = Set<members::org>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct roles(());
pub struct game(());
pub struct org(());
}
}
pub struct CreditBuilder<S: BosStr, St: credit_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Datetime>,
Option<S>,
Option<StrongRef<S>>,
Option<StrongRef<S>>,
Option<Vec<CompanyRole<S>>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Credit<S> {
pub fn new() -> CreditBuilder<S, credit_state::Empty> {
CreditBuilder::new()
}
}
impl<S: BosStr> CreditBuilder<S, credit_state::Empty> {
pub fn new() -> Self {
CreditBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: credit_state::State> CreditBuilder<S, St> {
pub fn created_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_created_at(mut self, value: Option<Datetime>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St: credit_state::State> CreditBuilder<S, St> {
pub fn display_name(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_display_name(mut self, value: Option<S>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> CreditBuilder<S, St>
where
St: credit_state::State,
St::Game: credit_state::IsUnset,
{
pub fn game(
mut self,
value: impl Into<StrongRef<S>>,
) -> CreditBuilder<S, credit_state::SetGame<St>> {
self._fields.2 = Option::Some(value.into());
CreditBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CreditBuilder<S, St>
where
St: credit_state::State,
St::Org: credit_state::IsUnset,
{
pub fn org(
mut self,
value: impl Into<StrongRef<S>>,
) -> CreditBuilder<S, credit_state::SetOrg<St>> {
self._fields.3 = Option::Some(value.into());
CreditBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CreditBuilder<S, St>
where
St: credit_state::State,
St::Roles: credit_state::IsUnset,
{
pub fn roles(
mut self,
value: impl Into<Vec<CompanyRole<S>>>,
) -> CreditBuilder<S, credit_state::SetRoles<St>> {
self._fields.4 = Option::Some(value.into());
CreditBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CreditBuilder<S, St>
where
St: credit_state::State,
St::Roles: credit_state::IsSet,
St::Game: credit_state::IsSet,
St::Org: credit_state::IsSet,
{
pub fn build(self) -> Credit<S> {
Credit {
created_at: self._fields.0,
display_name: self._fields.1,
game: self._fields.2.unwrap(),
org: self._fields.3.unwrap(),
roles: self._fields.4.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Credit<S> {
Credit {
created_at: self._fields.0,
display_name: self._fields.1,
game: self._fields.2.unwrap(),
org: self._fields.3.unwrap(),
roles: self._fields.4.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_games_gamesgamesgamesgames_org_credit() -> 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("games.gamesgamesgamesgames.org.credit"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static(
"A relationship between a game and an organization.",
),
),
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("org"), SmolStr::new_static("game"),
SmolStr::new_static("roles")
],
),
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("displayName"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The name to be used if there is no profile associated with this credit, or the profile is inaccessible.",
),
),
max_length: Some(640usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("game"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("org"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("roles"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static(
"games.gamesgamesgamesgames.defs#companyRole",
),
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}
}