#[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, Datetime};
use jacquard_common::types::uri::{RecordUri, UriError};
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;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
rename = "games.gamesgamesgamesgames.org.credit",
tag = "$type"
)]
pub struct Credit<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
pub created_at: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub display_name: Option<CowStr<'a>>,
#[serde(borrow)]
pub game: StrongRef<'a>,
#[serde(borrow)]
pub org: StrongRef<'a>,
#[serde(borrow)]
pub roles: Vec<CompanyRole<'a>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct CreditGetRecordOutput<'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: Credit<'a>,
}
impl<'a> Credit<'a> {
pub fn uri(
uri: impl Into<CowStr<'a>>,
) -> Result<RecordUri<'a, CreditRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
}
}
#[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<'de> = CreditGetRecordOutput<'de>;
type Err<'de> = RecordError<'de>;
}
impl From<CreditGetRecordOutput<'_>> for Credit<'_> {
fn from(output: CreditGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl Collection for Credit<'_> {
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<'a> LexiconSchema for Credit<'a> {
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 Org;
type Game;
type Roles;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Org = Unset;
type Game = Unset;
type Roles = Unset;
}
pub struct SetOrg<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetOrg<S> {}
impl<S: State> State for SetOrg<S> {
type Org = Set<members::org>;
type Game = S::Game;
type Roles = S::Roles;
}
pub struct SetGame<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetGame<S> {}
impl<S: State> State for SetGame<S> {
type Org = S::Org;
type Game = Set<members::game>;
type Roles = S::Roles;
}
pub struct SetRoles<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetRoles<S> {}
impl<S: State> State for SetRoles<S> {
type Org = S::Org;
type Game = S::Game;
type Roles = Set<members::roles>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct org(());
pub struct game(());
pub struct roles(());
}
}
pub struct CreditBuilder<'a, S: credit_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<Datetime>,
Option<CowStr<'a>>,
Option<StrongRef<'a>>,
Option<StrongRef<'a>>,
Option<Vec<CompanyRole<'a>>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Credit<'a> {
pub fn new() -> CreditBuilder<'a, credit_state::Empty> {
CreditBuilder::new()
}
}
impl<'a> CreditBuilder<'a, credit_state::Empty> {
pub fn new() -> Self {
CreditBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: credit_state::State> CreditBuilder<'a, S> {
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<'a, S: credit_state::State> CreditBuilder<'a, S> {
pub fn display_name(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_display_name(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S> CreditBuilder<'a, S>
where
S: credit_state::State,
S::Game: credit_state::IsUnset,
{
pub fn game(
mut self,
value: impl Into<StrongRef<'a>>,
) -> CreditBuilder<'a, credit_state::SetGame<S>> {
self._fields.2 = Option::Some(value.into());
CreditBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> CreditBuilder<'a, S>
where
S: credit_state::State,
S::Org: credit_state::IsUnset,
{
pub fn org(
mut self,
value: impl Into<StrongRef<'a>>,
) -> CreditBuilder<'a, credit_state::SetOrg<S>> {
self._fields.3 = Option::Some(value.into());
CreditBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> CreditBuilder<'a, S>
where
S: credit_state::State,
S::Roles: credit_state::IsUnset,
{
pub fn roles(
mut self,
value: impl Into<Vec<CompanyRole<'a>>>,
) -> CreditBuilder<'a, credit_state::SetRoles<S>> {
self._fields.4 = Option::Some(value.into());
CreditBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> CreditBuilder<'a, S>
where
S: credit_state::State,
S::Org: credit_state::IsSet,
S::Game: credit_state::IsSet,
S::Roles: credit_state::IsSet,
{
pub fn build(self) -> Credit<'a> {
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<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Credit<'a> {
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()
}
}