jacquard-api 0.11.0

Generated AT Protocol API bindings for Jacquard
Documentation
// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: app.ocho.server.swapLaunchToken
//
// 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;
use jacquard_common::types::string::Did;
use jacquard_derive::{IntoStatic, lexicon};
use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct SwapLaunchToken<'a> {
    #[serde(borrow)]
    pub launch_token: CowStr<'a>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct SwapLaunchTokenOutput<'a> {
    ///The did of the user
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub did: Option<Did<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub handle: Option<CowStr<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub name: Option<CowStr<'a>>,
    #[serde(borrow)]
    pub token: CowStr<'a>,
}

/// Response type for app.ocho.server.swapLaunchToken
pub struct SwapLaunchTokenResponse;
impl jacquard_common::xrpc::XrpcResp for SwapLaunchTokenResponse {
    const NSID: &'static str = "app.ocho.server.swapLaunchToken";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = SwapLaunchTokenOutput<'de>;
    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}

impl<'a> jacquard_common::xrpc::XrpcRequest for SwapLaunchToken<'a> {
    const NSID: &'static str = "app.ocho.server.swapLaunchToken";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = SwapLaunchTokenResponse;
}

/// Endpoint type for app.ocho.server.swapLaunchToken
pub struct SwapLaunchTokenRequest;
impl jacquard_common::xrpc::XrpcEndpoint for SwapLaunchTokenRequest {
    const PATH: &'static str = "/xrpc/app.ocho.server.swapLaunchToken";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<'de> = SwapLaunchToken<'de>;
    type Response = SwapLaunchTokenResponse;
}

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

/// Builder for constructing an instance of this type
pub struct SwapLaunchTokenBuilder<'a, S: swap_launch_token_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<CowStr<'a>>,),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> SwapLaunchToken<'a> {
    /// Create a new builder for this type
    pub fn new() -> SwapLaunchTokenBuilder<'a, swap_launch_token_state::Empty> {
        SwapLaunchTokenBuilder::new()
    }
}

impl<'a> SwapLaunchTokenBuilder<'a, swap_launch_token_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        SwapLaunchTokenBuilder {
            _state: PhantomData,
            _fields: (None,),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SwapLaunchTokenBuilder<'a, S>
where
    S: swap_launch_token_state::State,
    S::LaunchToken: swap_launch_token_state::IsUnset,
{
    /// Set the `launchToken` field (required)
    pub fn launch_token(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> SwapLaunchTokenBuilder<'a, swap_launch_token_state::SetLaunchToken<S>> {
        self._fields.0 = Option::Some(value.into());
        SwapLaunchTokenBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SwapLaunchTokenBuilder<'a, S>
where
    S: swap_launch_token_state::State,
    S::LaunchToken: swap_launch_token_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> SwapLaunchToken<'a> {
        SwapLaunchToken {
            launch_token: self._fields.0.unwrap(),
        }
    }
}