#[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::string::{Did, Handle, Datetime};
use jacquard_common::types::value::Data;
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::network_slices::slice::get_actors;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Actor<'a> {
#[serde(borrow)]
pub did: Did<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub handle: Option<Handle<'a>>,
pub indexed_at: Datetime,
#[serde(borrow)]
pub slice_uri: CowStr<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetActors<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cursor: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default = "_default_get_actors_limit")]
pub limit: Option<i64>,
#[serde(borrow)]
pub slice: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub r#where: Option<Data<'a>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetActorsOutput<'a> {
#[serde(borrow)]
pub actors: Vec<get_actors::Actor<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cursor: Option<CowStr<'a>>,
}
impl<'a> LexiconSchema for Actor<'a> {
fn nsid() -> &'static str {
"network.slices.slice.getActors"
}
fn def_name() -> &'static str {
"actor"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_network_slices_slice_getActors()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub struct GetActorsResponse;
impl jacquard_common::xrpc::XrpcResp for GetActorsResponse {
const NSID: &'static str = "network.slices.slice.getActors";
const ENCODING: &'static str = "application/json";
type Output<'de> = GetActorsOutput<'de>;
type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}
impl<'a> jacquard_common::xrpc::XrpcRequest for GetActors<'a> {
const NSID: &'static str = "network.slices.slice.getActors";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Response = GetActorsResponse;
}
pub struct GetActorsRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetActorsRequest {
const PATH: &'static str = "/xrpc/network.slices.slice.getActors";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Request<'de> = GetActors<'de>;
type Response = GetActorsResponse;
}
pub mod actor_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 IndexedAt;
type SliceUri;
type Did;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type IndexedAt = Unset;
type SliceUri = Unset;
type Did = Unset;
}
pub struct SetIndexedAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetIndexedAt<S> {}
impl<S: State> State for SetIndexedAt<S> {
type IndexedAt = Set<members::indexed_at>;
type SliceUri = S::SliceUri;
type Did = S::Did;
}
pub struct SetSliceUri<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetSliceUri<S> {}
impl<S: State> State for SetSliceUri<S> {
type IndexedAt = S::IndexedAt;
type SliceUri = Set<members::slice_uri>;
type Did = S::Did;
}
pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetDid<S> {}
impl<S: State> State for SetDid<S> {
type IndexedAt = S::IndexedAt;
type SliceUri = S::SliceUri;
type Did = Set<members::did>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct indexed_at(());
pub struct slice_uri(());
pub struct did(());
}
}
pub struct ActorBuilder<'a, S: actor_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<Did<'a>>, Option<Handle<'a>>, Option<Datetime>, Option<CowStr<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Actor<'a> {
pub fn new() -> ActorBuilder<'a, actor_state::Empty> {
ActorBuilder::new()
}
}
impl<'a> ActorBuilder<'a, actor_state::Empty> {
pub fn new() -> Self {
ActorBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> ActorBuilder<'a, S>
where
S: actor_state::State,
S::Did: actor_state::IsUnset,
{
pub fn did(
mut self,
value: impl Into<Did<'a>>,
) -> ActorBuilder<'a, actor_state::SetDid<S>> {
self._fields.0 = Option::Some(value.into());
ActorBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: actor_state::State> ActorBuilder<'a, S> {
pub fn handle(mut self, value: impl Into<Option<Handle<'a>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_handle(mut self, value: Option<Handle<'a>>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S> ActorBuilder<'a, S>
where
S: actor_state::State,
S::IndexedAt: actor_state::IsUnset,
{
pub fn indexed_at(
mut self,
value: impl Into<Datetime>,
) -> ActorBuilder<'a, actor_state::SetIndexedAt<S>> {
self._fields.2 = Option::Some(value.into());
ActorBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ActorBuilder<'a, S>
where
S: actor_state::State,
S::SliceUri: actor_state::IsUnset,
{
pub fn slice_uri(
mut self,
value: impl Into<CowStr<'a>>,
) -> ActorBuilder<'a, actor_state::SetSliceUri<S>> {
self._fields.3 = Option::Some(value.into());
ActorBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ActorBuilder<'a, S>
where
S: actor_state::State,
S::IndexedAt: actor_state::IsSet,
S::SliceUri: actor_state::IsSet,
S::Did: actor_state::IsSet,
{
pub fn build(self) -> Actor<'a> {
Actor {
did: self._fields.0.unwrap(),
handle: self._fields.1,
indexed_at: self._fields.2.unwrap(),
slice_uri: self._fields.3.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
) -> Actor<'a> {
Actor {
did: self._fields.0.unwrap(),
handle: self._fields.1,
indexed_at: self._fields.2.unwrap(),
slice_uri: self._fields.3.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_network_slices_slice_getActors() -> 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.slice.getActors"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("actor"),
LexUserType::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("did"), SmolStr::new_static("sliceUri"),
SmolStr::new_static("indexedAt")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("did"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Decentralized identifier of the actor"),
),
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("handle"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Human-readable handle of the actor"),
),
format: Some(LexStringFormat::Handle),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("indexedAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("When this actor was indexed"),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("sliceUri"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"AT-URI of the slice this actor is indexed in",
),
),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::XrpcProcedure(LexXrpcProcedure {
input: Some(LexXrpcBody {
encoding: CowStr::new_static("application/json"),
schema: Some(
LexXrpcBodySchema::Object(LexObject {
required: Some(vec![SmolStr::new_static("slice")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("cursor"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Pagination cursor from previous response",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("limit"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(1i64),
maximum: Some(100i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("slice"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("AT-URI of the slice to query"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("where"),
LexObjectProperty::Unknown(LexUnknown {
..Default::default()
}),
);
map
},
..Default::default()
}),
),
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}
}
fn _default_get_actors_limit() -> Option<i64> {
Some(50i64)
}