jacquard-api 0.11.0

Generated AT Protocol API bindings for Jacquard
Documentation
// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: place.stream.graph.getFollowingUser
//
// 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::types::string::Did;
use jacquard_derive::{IntoStatic, lexicon};
use serde::{Serialize, Deserialize};
use crate::com_atproto::repo::strong_ref::StrongRef;

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


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetFollowingUserOutput<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub follow: Option<StrongRef<'a>>,
}

/// Response type for place.stream.graph.getFollowingUser
pub struct GetFollowingUserResponse;
impl jacquard_common::xrpc::XrpcResp for GetFollowingUserResponse {
    const NSID: &'static str = "place.stream.graph.getFollowingUser";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = GetFollowingUserOutput<'de>;
    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}

impl<'a> jacquard_common::xrpc::XrpcRequest for GetFollowingUser<'a> {
    const NSID: &'static str = "place.stream.graph.getFollowingUser";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = GetFollowingUserResponse;
}

/// Endpoint type for place.stream.graph.getFollowingUser
pub struct GetFollowingUserRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetFollowingUserRequest {
    const PATH: &'static str = "/xrpc/place.stream.graph.getFollowingUser";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<'de> = GetFollowingUser<'de>;
    type Response = GetFollowingUserResponse;
}

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

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

impl<'a> GetFollowingUser<'a> {
    /// Create a new builder for this type
    pub fn new() -> GetFollowingUserBuilder<'a, get_following_user_state::Empty> {
        GetFollowingUserBuilder::new()
    }
}

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

impl<'a, S> GetFollowingUserBuilder<'a, S>
where
    S: get_following_user_state::State,
    S::SubjectDid: get_following_user_state::IsUnset,
{
    /// Set the `subjectDID` field (required)
    pub fn subject_did(
        mut self,
        value: impl Into<Did<'a>>,
    ) -> GetFollowingUserBuilder<'a, get_following_user_state::SetSubjectDid<S>> {
        self._fields.0 = Option::Some(value.into());
        GetFollowingUserBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> GetFollowingUserBuilder<'a, S>
where
    S: get_following_user_state::State,
    S::UserDid: get_following_user_state::IsUnset,
{
    /// Set the `userDID` field (required)
    pub fn user_did(
        mut self,
        value: impl Into<Did<'a>>,
    ) -> GetFollowingUserBuilder<'a, get_following_user_state::SetUserDid<S>> {
        self._fields.1 = Option::Some(value.into());
        GetFollowingUserBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> GetFollowingUserBuilder<'a, S>
where
    S: get_following_user_state::State,
    S::SubjectDid: get_following_user_state::IsSet,
    S::UserDid: get_following_user_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> GetFollowingUser<'a> {
        GetFollowingUser {
            subject_did: self._fields.0.unwrap(),
            user_did: self._fields.1.unwrap(),
        }
    }
}