#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::{Datetime, Did, Handle};
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::network_slices::slice::get_actors;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Actor<S: BosStr = DefaultStr> {
pub did: Did<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub handle: Option<Handle<S>>,
pub indexed_at: Datetime,
pub slice_uri: 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, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct GetActors<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cursor: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default = "_default_get_actors_limit")]
pub limit: Option<i64>,
pub slice: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub r#where: Option<Data<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",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct GetActorsOutput<S: BosStr = DefaultStr> {
pub actors: Vec<get_actors::Actor<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub cursor: Option<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> LexiconSchema for Actor<S> {
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<S: BosStr> = GetActorsOutput<S>;
type Err = jacquard_common::xrpc::GenericError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for GetActors<S> {
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<S: BosStr> = GetActors<S>;
type Response = GetActorsResponse;
}
pub mod actor_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type SliceUri;
type Did;
type IndexedAt;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type SliceUri = Unset;
type Did = Unset;
type IndexedAt = Unset;
}
pub struct SetSliceUri<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSliceUri<St> {}
impl<St: State> State for SetSliceUri<St> {
type SliceUri = Set<members::slice_uri>;
type Did = St::Did;
type IndexedAt = St::IndexedAt;
}
pub struct SetDid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDid<St> {}
impl<St: State> State for SetDid<St> {
type SliceUri = St::SliceUri;
type Did = Set<members::did>;
type IndexedAt = St::IndexedAt;
}
pub struct SetIndexedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetIndexedAt<St> {}
impl<St: State> State for SetIndexedAt<St> {
type SliceUri = St::SliceUri;
type Did = St::Did;
type IndexedAt = Set<members::indexed_at>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct slice_uri(());
pub struct did(());
pub struct indexed_at(());
}
}
pub struct ActorBuilder<S: BosStr, St: actor_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Did<S>>,
Option<Handle<S>>,
Option<Datetime>,
Option<S>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Actor<S> {
pub fn new() -> ActorBuilder<S, actor_state::Empty> {
ActorBuilder::new()
}
}
impl<S: BosStr> ActorBuilder<S, actor_state::Empty> {
pub fn new() -> Self {
ActorBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ActorBuilder<S, St>
where
St: actor_state::State,
St::Did: actor_state::IsUnset,
{
pub fn did(mut self, value: impl Into<Did<S>>) -> ActorBuilder<S, actor_state::SetDid<St>> {
self._fields.0 = Option::Some(value.into());
ActorBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: actor_state::State> ActorBuilder<S, St> {
pub fn handle(mut self, value: impl Into<Option<Handle<S>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_handle(mut self, value: Option<Handle<S>>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> ActorBuilder<S, St>
where
St: actor_state::State,
St::IndexedAt: actor_state::IsUnset,
{
pub fn indexed_at(
mut self,
value: impl Into<Datetime>,
) -> ActorBuilder<S, actor_state::SetIndexedAt<St>> {
self._fields.2 = Option::Some(value.into());
ActorBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ActorBuilder<S, St>
where
St: actor_state::State,
St::SliceUri: actor_state::IsUnset,
{
pub fn slice_uri(
mut self,
value: impl Into<S>,
) -> ActorBuilder<S, actor_state::SetSliceUri<St>> {
self._fields.3 = Option::Some(value.into());
ActorBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ActorBuilder<S, St>
where
St: actor_state::State,
St::SliceUri: actor_state::IsSet,
St::Did: actor_state::IsSet,
St::IndexedAt: actor_state::IsSet,
{
pub fn build(self) -> Actor<S> {
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<SmolStr, Data<S>>) -> Actor<S> {
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> {
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
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)
}