#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::Did;
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, open_union};
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct GetQuota<S: BosStr = DefaultStr> {
pub user_did: Did<S>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct GetQuotaOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub tier: Option<S>,
pub total_size: i64,
pub unique_blobs: i64,
pub user_did: Did<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,
thiserror::Error,
miette::Diagnostic
)]
#[serde(tag = "error", content = "message")]
pub enum GetQuotaError {
#[serde(rename = "InvalidUserDid")]
InvalidUserDid(Option<SmolStr>),
#[serde(untagged)]
Other { error: SmolStr, message: Option<SmolStr> },
}
impl core::fmt::Display for GetQuotaError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::InvalidUserDid(msg) => {
write!(f, "InvalidUserDid")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::Other { error, message } => {
write!(f, "{}", error)?;
if let Some(msg) = message {
write!(f, ": {}", msg)?;
}
Ok(())
}
}
}
}
pub struct GetQuotaResponse;
impl jacquard_common::xrpc::XrpcResp for GetQuotaResponse {
const NSID: &'static str = "io.atcr.hold.getQuota";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = GetQuotaOutput<S>;
type Err = GetQuotaError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for GetQuota<S> {
const NSID: &'static str = "io.atcr.hold.getQuota";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Response = GetQuotaResponse;
}
pub struct GetQuotaRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetQuotaRequest {
const PATH: &'static str = "/xrpc/io.atcr.hold.getQuota";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Request<S: BosStr> = GetQuota<S>;
type Response = GetQuotaResponse;
}
pub mod get_quota_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 UserDid;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type UserDid = Unset;
}
pub struct SetUserDid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetUserDid<St> {}
impl<St: State> State for SetUserDid<St> {
type UserDid = Set<members::user_did>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct user_did(());
}
}
pub struct GetQuotaBuilder<S: BosStr, St: get_quota_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Did<S>>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> GetQuota<S> {
pub fn new() -> GetQuotaBuilder<S, get_quota_state::Empty> {
GetQuotaBuilder::new()
}
}
impl<S: BosStr> GetQuotaBuilder<S, get_quota_state::Empty> {
pub fn new() -> Self {
GetQuotaBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> GetQuotaBuilder<S, St>
where
St: get_quota_state::State,
St::UserDid: get_quota_state::IsUnset,
{
pub fn user_did(
mut self,
value: impl Into<Did<S>>,
) -> GetQuotaBuilder<S, get_quota_state::SetUserDid<St>> {
self._fields.0 = Option::Some(value.into());
GetQuotaBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> GetQuotaBuilder<S, St>
where
St: get_quota_state::State,
St::UserDid: get_quota_state::IsSet,
{
pub fn build(self) -> GetQuota<S> {
GetQuota {
user_did: self._fields.0.unwrap(),
}
}
}