#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct Credit<'a> {
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub actor: std::option::Option<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
#[serde(borrow)]
pub credits: Vec<crate::games_gamesgamesgamesgames::CreditEntry<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub display_name: std::option::Option<jacquard_common::CowStr<'a>>,
#[serde(borrow)]
pub game: crate::com_atproto::repo::strong_ref::StrongRef<'a>,
}
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 Game;
type Credits;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Game = Unset;
type Credits = Unset;
}
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 Game = Set<members::game>;
type Credits = S::Credits;
}
pub struct SetCredits<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCredits<S> {}
impl<S: State> State for SetCredits<S> {
type Game = S::Game;
type Credits = Set<members::credits>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct game(());
pub struct credits(());
}
}
pub struct CreditBuilder<'a, S: credit_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
::core::option::Option<Vec<crate::games_gamesgamesgamesgames::CreditEntry<'a>>>,
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
),
_phantom: ::core::marker::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 {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: (None, None, None, None),
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: credit_state::State> CreditBuilder<'a, S> {
pub fn actor(
mut self,
value: impl Into<Option<crate::com_atproto::repo::strong_ref::StrongRef<'a>>>,
) -> Self {
self.__unsafe_private_named.0 = value.into();
self
}
pub fn maybe_actor(
mut self,
value: Option<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
) -> Self {
self.__unsafe_private_named.0 = value;
self
}
}
impl<'a, S> CreditBuilder<'a, S>
where
S: credit_state::State,
S::Credits: credit_state::IsUnset,
{
pub fn credits(
mut self,
value: impl Into<Vec<crate::games_gamesgamesgamesgames::CreditEntry<'a>>>,
) -> CreditBuilder<'a, credit_state::SetCredits<S>> {
self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
CreditBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: credit_state::State> CreditBuilder<'a, S> {
pub fn display_name(
mut self,
value: impl Into<Option<jacquard_common::CowStr<'a>>>,
) -> Self {
self.__unsafe_private_named.2 = value.into();
self
}
pub fn maybe_display_name(
mut self,
value: Option<jacquard_common::CowStr<'a>>,
) -> Self {
self.__unsafe_private_named.2 = 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<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
) -> CreditBuilder<'a, credit_state::SetGame<S>> {
self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into());
CreditBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> CreditBuilder<'a, S>
where
S: credit_state::State,
S::Game: credit_state::IsSet,
S::Credits: credit_state::IsSet,
{
pub fn build(self) -> Credit<'a> {
Credit {
actor: self.__unsafe_private_named.0,
credits: self.__unsafe_private_named.1.unwrap(),
display_name: self.__unsafe_private_named.2,
game: self.__unsafe_private_named.3.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: std::collections::BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Credit<'a> {
Credit {
actor: self.__unsafe_private_named.0,
credits: self.__unsafe_private_named.1.unwrap(),
display_name: self.__unsafe_private_named.2,
game: self.__unsafe_private_named.3.unwrap(),
extra_data: Some(extra_data),
}
}
}
impl<'a> Credit<'a> {
pub fn uri(
uri: impl Into<jacquard_common::CowStr<'a>>,
) -> Result<
jacquard_common::types::uri::RecordUri<'a, CreditRecord>,
jacquard_common::types::uri::UriError,
> {
jacquard_common::types::uri::RecordUri::try_from_uri(
jacquard_common::types::string::AtUri::new_cow(uri.into())?,
)
}
}
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct CreditGetRecordOutput<'a> {
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
#[serde(borrow)]
pub uri: jacquard_common::types::string::AtUri<'a>,
#[serde(borrow)]
pub value: Credit<'a>,
}
impl From<CreditGetRecordOutput<'_>> for Credit<'_> {
fn from(output: CreditGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl jacquard_common::types::collection::Collection for Credit<'_> {
const NSID: &'static str = "games.gamesgamesgamesgames.actor.credit";
type Record = CreditRecord;
}
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct CreditRecord;
impl jacquard_common::xrpc::XrpcResp for CreditRecord {
const NSID: &'static str = "games.gamesgamesgamesgames.actor.credit";
const ENCODING: &'static str = "application/json";
type Output<'de> = CreditGetRecordOutput<'de>;
type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
}
impl jacquard_common::types::collection::Collection for CreditRecord {
const NSID: &'static str = "games.gamesgamesgamesgames.actor.credit";
type Record = CreditRecord;
}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Credit<'a> {
fn nsid() -> &'static str {
"games.gamesgamesgamesgames.actor.credit"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
lexicon_doc_games_gamesgamesgamesgames_actor_credit()
}
fn validate(
&self,
) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
if let Some(ref value) = self.display_name {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 640usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"display_name",
),
max: 640usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
fn lexicon_doc_games_gamesgamesgamesgames_actor_credit() -> ::jacquard_lexicon::lexicon::LexiconDoc<
'static,
> {
::jacquard_lexicon::lexicon::LexiconDoc {
lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
id: ::jacquard_common::CowStr::new_static(
"games.gamesgamesgamesgames.actor.credit",
),
revision: None,
description: None,
defs: {
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static("main"),
::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord {
description: Some(
::jacquard_common::CowStr::new_static(
"A relationship between a game and a profile.",
),
),
key: Some(::jacquard_common::CowStr::new_static("tid")),
record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject {
description: None,
required: Some(
vec![
::jacquard_common::deps::smol_str::SmolStr::new_static("game"),
::jacquard_common::deps::smol_str::SmolStr::new_static("credits")
],
),
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"actor",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"com.atproto.repo.strongRef",
),
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"credits",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
description: Some(
::jacquard_common::CowStr::new_static(
"The roles this profile played in the creation of the game.",
),
),
items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"games.gamesgamesgamesgames.defs#creditEntry",
),
}),
min_length: None,
max_length: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"displayName",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"The name to be used if there is no profile associated with this credit, or the profile is inaccessible.",
),
),
format: None,
default: None,
min_length: None,
max_length: Some(640usize),
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"game",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"com.atproto.repo.strongRef",
),
}),
);
map
},
}),
}),
);
map
},
}
}