jacquard-api 0.10.2

Generated AT Protocol API bindings for Jacquard
Documentation
// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: io.atcr.hold.getQuota
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

#[derive(
    serde::Serialize,
    serde::Deserialize,
    Debug,
    Clone,
    PartialEq,
    Eq,
    jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct GetQuota<'a> {
    #[serde(borrow)]
    pub user_did: jacquard_common::types::string::Did<'a>,
}

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 {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type UserDid;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type UserDid = Unset;
    }
    ///State transition - sets the `user_did` field to Set
    pub struct SetUserDid<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetUserDid<S> {}
    impl<S: State> State for SetUserDid<S> {
        type UserDid = Set<members::user_did>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `user_did` field
        pub struct user_did(());
    }
}

/// Builder for constructing an instance of this type
pub struct GetQuotaBuilder<'a, S: get_quota_state::State> {
    _phantom_state: ::core::marker::PhantomData<fn() -> S>,
    __unsafe_private_named: (
        ::core::option::Option<jacquard_common::types::string::Did<'a>>,
    ),
    _phantom: ::core::marker::PhantomData<&'a ()>,
}

impl<'a> GetQuota<'a> {
    /// Create a new builder for this type
    pub fn new() -> GetQuotaBuilder<'a, get_quota_state::Empty> {
        GetQuotaBuilder::new()
    }
}

impl<'a> GetQuotaBuilder<'a, get_quota_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        GetQuotaBuilder {
            _phantom_state: ::core::marker::PhantomData,
            __unsafe_private_named: (None,),
            _phantom: ::core::marker::PhantomData,
        }
    }
}

impl<'a, S> GetQuotaBuilder<'a, S>
where
    S: get_quota_state::State,
    S::UserDid: get_quota_state::IsUnset,
{
    /// Set the `userDid` field (required)
    pub fn user_did(
        mut self,
        value: impl Into<jacquard_common::types::string::Did<'a>>,
    ) -> GetQuotaBuilder<'a, get_quota_state::SetUserDid<S>> {
        self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
        GetQuotaBuilder {
            _phantom_state: ::core::marker::PhantomData,
            __unsafe_private_named: self.__unsafe_private_named,
            _phantom: ::core::marker::PhantomData,
        }
    }
}

impl<'a, S> GetQuotaBuilder<'a, S>
where
    S: get_quota_state::State,
    S::UserDid: get_quota_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> GetQuota<'a> {
        GetQuota {
            user_did: self.__unsafe_private_named.0.unwrap(),
        }
    }
}

#[jacquard_derive::lexicon]
#[derive(
    serde::Serialize,
    serde::Deserialize,
    Debug,
    Clone,
    PartialEq,
    Eq,
    jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct GetQuotaOutput<'a> {
    ///Storage limit in bytes (absent if unlimited)
    #[serde(skip_serializing_if = "std::option::Option::is_none")]
    pub limit: std::option::Option<i64>,
    ///Quota tier name (e.g., 'deckhand', 'bosun', 'quartermaster')
    #[serde(skip_serializing_if = "std::option::Option::is_none")]
    #[serde(borrow)]
    pub tier: std::option::Option<jacquard_common::CowStr<'a>>,
    ///Total size in bytes of unique blobs
    pub total_size: i64,
    ///Number of unique blob digests
    pub unique_blobs: i64,
    ///DID of the user
    #[serde(borrow)]
    pub user_did: jacquard_common::types::string::Did<'a>,
}

#[jacquard_derive::open_union]
#[derive(
    serde::Serialize,
    serde::Deserialize,
    Debug,
    Clone,
    PartialEq,
    Eq,
    thiserror::Error,
    miette::Diagnostic,
    jacquard_derive::IntoStatic
)]
#[serde(tag = "error", content = "message")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum GetQuotaError<'a> {
    #[serde(rename = "InvalidUserDid")]
    InvalidUserDid(std::option::Option<jacquard_common::CowStr<'a>>),
}

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::Unknown(err) => write!(f, "Unknown error: {:?}", err),
        }
    }
}

/// Response type for
///io.atcr.hold.getQuota
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<'de> = GetQuotaOutput<'de>;
    type Err<'de> = GetQuotaError<'de>;
}

impl<'a> jacquard_common::xrpc::XrpcRequest for GetQuota<'a> {
    const NSID: &'static str = "io.atcr.hold.getQuota";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = GetQuotaResponse;
}

/// Endpoint type for
///io.atcr.hold.getQuota
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<'de> = GetQuota<'de>;
    type Response = GetQuotaResponse;
}