jacquard-api 0.11.1

Generated AT Protocol API bindings for Jacquard
Documentation
// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: chat.bsky.convo.getConvo
//
// 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_derive::{IntoStatic, lexicon};
use serde::{Serialize, Deserialize};
use crate::chat_bsky::convo::ConvoView;

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


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

/// Response type for chat.bsky.convo.getConvo
pub struct GetConvoResponse;
impl jacquard_common::xrpc::XrpcResp for GetConvoResponse {
    const NSID: &'static str = "chat.bsky.convo.getConvo";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = GetConvoOutput<'de>;
    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}

impl<'a> jacquard_common::xrpc::XrpcRequest for GetConvo<'a> {
    const NSID: &'static str = "chat.bsky.convo.getConvo";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = GetConvoResponse;
}

/// Endpoint type for chat.bsky.convo.getConvo
pub struct GetConvoRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetConvoRequest {
    const PATH: &'static str = "/xrpc/chat.bsky.convo.getConvo";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<'de> = GetConvo<'de>;
    type Response = GetConvoResponse;
}

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

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

impl<'a> GetConvo<'a> {
    /// Create a new builder for this type
    pub fn new() -> GetConvoBuilder<'a, get_convo_state::Empty> {
        GetConvoBuilder::new()
    }
}

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

impl<'a, S> GetConvoBuilder<'a, S>
where
    S: get_convo_state::State,
    S::ConvoId: get_convo_state::IsUnset,
{
    /// Set the `convoId` field (required)
    pub fn convo_id(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> GetConvoBuilder<'a, get_convo_state::SetConvoId<S>> {
        self._fields.0 = Option::Some(value.into());
        GetConvoBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> GetConvoBuilder<'a, S>
where
    S: get_convo_state::State,
    S::ConvoId: get_convo_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> GetConvo<'a> {
        GetConvo {
            convo_id: self._fields.0.unwrap(),
        }
    }
}