// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: network.slices.waitlist.invite // // 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::{Did, 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}; /// An invite granting a DID access, created by the slice owner #[lexicon] #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] #[serde(rename_all = "camelCase")] pub struct Invite<'a> { ///When this invitation was created pub created_at: Datetime, ///The DID being invited #[serde(borrow)] pub did: Did<'a>, ///Optional expiration date for this invitation #[serde(skip_serializing_if = "Option::is_none")] pub expires_at: Option, ///The AT URI of the slice this invite is for #[serde(borrow)] pub slice: AtUri<'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 InviteGetRecordOutput<'a> { #[serde(skip_serializing_if = "Option::is_none")] #[serde(borrow)] pub cid: Option>, #[serde(borrow)] pub uri: AtUri<'a>, #[serde(borrow)] pub value: Invite<'a>, } impl<'a> Invite<'a> { pub fn uri( uri: impl Into>, ) -> Result, UriError> { RecordUri::try_from_uri(AtUri::new_cow(uri.into())?) } } /// Marker type for deserializing records from this collection. #[derive(Debug, Serialize, Deserialize)] pub struct InviteRecord; impl XrpcResp for InviteRecord { const NSID: &'static str = "network.slices.waitlist.invite"; const ENCODING: &'static str = "application/json"; type Output<'de> = InviteGetRecordOutput<'de>; type Err<'de> = RecordError<'de>; } impl From> for Invite<'_> { fn from(output: InviteGetRecordOutput<'_>) -> Self { use jacquard_common::IntoStatic; output.value.into_static() } } impl Collection for Invite<'_> { const NSID: &'static str = "network.slices.waitlist.invite"; type Record = InviteRecord; } impl Collection for InviteRecord { const NSID: &'static str = "network.slices.waitlist.invite"; type Record = InviteRecord; } impl<'a> LexiconSchema for Invite<'a> { fn nsid() -> &'static str { "network.slices.waitlist.invite" } fn def_name() -> &'static str { "main" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_network_slices_waitlist_invite() } fn validate(&self) -> Result<(), ConstraintError> { Ok(()) } } pub mod invite_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 Slice; type Did; type CreatedAt; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Slice = Unset; type Did = Unset; type CreatedAt = Unset; } ///State transition - sets the `slice` field to Set pub struct SetSlice(PhantomData S>); impl sealed::Sealed for SetSlice {} impl State for SetSlice { type Slice = Set; type Did = S::Did; type CreatedAt = S::CreatedAt; } ///State transition - sets the `did` field to Set pub struct SetDid(PhantomData S>); impl sealed::Sealed for SetDid {} impl State for SetDid { type Slice = S::Slice; type Did = Set; type CreatedAt = S::CreatedAt; } ///State transition - sets the `created_at` field to Set pub struct SetCreatedAt(PhantomData S>); impl sealed::Sealed for SetCreatedAt {} impl State for SetCreatedAt { type Slice = S::Slice; type Did = S::Did; type CreatedAt = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `slice` field pub struct slice(()); ///Marker type for the `did` field pub struct did(()); ///Marker type for the `created_at` field pub struct created_at(()); } } /// Builder for constructing an instance of this type pub struct InviteBuilder<'a, S: invite_state::State> { _state: PhantomData S>, _fields: (Option, Option>, Option, Option>), _lifetime: PhantomData<&'a ()>, } impl<'a> Invite<'a> { /// Create a new builder for this type pub fn new() -> InviteBuilder<'a, invite_state::Empty> { InviteBuilder::new() } } impl<'a> InviteBuilder<'a, invite_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { InviteBuilder { _state: PhantomData, _fields: (None, None, None, None), _lifetime: PhantomData, } } } impl<'a, S> InviteBuilder<'a, S> where S: invite_state::State, S::CreatedAt: invite_state::IsUnset, { /// Set the `createdAt` field (required) pub fn created_at( mut self, value: impl Into, ) -> InviteBuilder<'a, invite_state::SetCreatedAt> { self._fields.0 = Option::Some(value.into()); InviteBuilder { _state: PhantomData, _fields: self._fields, _lifetime: PhantomData, } } } impl<'a, S> InviteBuilder<'a, S> where S: invite_state::State, S::Did: invite_state::IsUnset, { /// Set the `did` field (required) pub fn did( mut self, value: impl Into>, ) -> InviteBuilder<'a, invite_state::SetDid> { self._fields.1 = Option::Some(value.into()); InviteBuilder { _state: PhantomData, _fields: self._fields, _lifetime: PhantomData, } } } impl<'a, S: invite_state::State> InviteBuilder<'a, S> { /// Set the `expiresAt` field (optional) pub fn expires_at(mut self, value: impl Into>) -> Self { self._fields.2 = value.into(); self } /// Set the `expiresAt` field to an Option value (optional) pub fn maybe_expires_at(mut self, value: Option) -> Self { self._fields.2 = value; self } } impl<'a, S> InviteBuilder<'a, S> where S: invite_state::State, S::Slice: invite_state::IsUnset, { /// Set the `slice` field (required) pub fn slice( mut self, value: impl Into>, ) -> InviteBuilder<'a, invite_state::SetSlice> { self._fields.3 = Option::Some(value.into()); InviteBuilder { _state: PhantomData, _fields: self._fields, _lifetime: PhantomData, } } } impl<'a, S> InviteBuilder<'a, S> where S: invite_state::State, S::Slice: invite_state::IsSet, S::Did: invite_state::IsSet, S::CreatedAt: invite_state::IsSet, { /// Build the final struct pub fn build(self) -> Invite<'a> { Invite { created_at: self._fields.0.unwrap(), did: self._fields.1.unwrap(), expires_at: self._fields.2, slice: 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< jacquard_common::deps::smol_str::SmolStr, jacquard_common::types::value::Data<'a>, >, ) -> Invite<'a> { Invite { created_at: self._fields.0.unwrap(), did: self._fields.1.unwrap(), expires_at: self._fields.2, slice: self._fields.3.unwrap(), extra_data: Some(extra_data), } } } fn lexicon_doc_network_slices_waitlist_invite() -> 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("network.slices.waitlist.invite"), defs: { let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("main"), LexUserType::Record(LexRecord { description: Some( CowStr::new_static( "An invite granting a DID access, created by the slice owner", ), ), key: Some(CowStr::new_static("tid")), record: LexRecordRecord::Object(LexObject { required: Some( vec![ SmolStr::new_static("did"), SmolStr::new_static("slice"), SmolStr::new_static("createdAt") ], ), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("createdAt"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static("When this invitation was created"), ), format: Some(LexStringFormat::Datetime), ..Default::default() }), ); map.insert( SmolStr::new_static("did"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static("The DID being invited"), ), format: Some(LexStringFormat::Did), ..Default::default() }), ); map.insert( SmolStr::new_static("expiresAt"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static( "Optional expiration date for this invitation", ), ), format: Some(LexStringFormat::Datetime), ..Default::default() }), ); map.insert( SmolStr::new_static("slice"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static( "The AT URI of the slice this invite is for", ), ), format: Some(LexStringFormat::AtUri), ..Default::default() }), ); map }, ..Default::default() }), ..Default::default() }), ); map }, ..Default::default() } }