jacquard-api 0.10.2

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

#[jacquard_derive::lexicon]
#[derive(
    serde::Serialize,
    serde::Deserialize,
    Debug,
    Clone,
    PartialEq,
    Eq,
    jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct Editor<'a> {
    ///AT-URI of the component record to edit
    #[serde(borrow)]
    pub uri: jacquard_common::types::string::AtUri<'a>,
}

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

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

impl<'a> Editor<'a> {
    /// Create a new builder for this type
    pub fn new() -> EditorBuilder<'a, editor_state::Empty> {
        EditorBuilder::new()
    }
}

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

impl<'a, S> EditorBuilder<'a, S>
where
    S: editor_state::State,
    S::Uri: editor_state::IsUnset,
{
    /// Set the `uri` field (required)
    pub fn uri(
        mut self,
        value: impl Into<jacquard_common::types::string::AtUri<'a>>,
    ) -> EditorBuilder<'a, editor_state::SetUri<S>> {
        self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
        EditorBuilder {
            _phantom_state: ::core::marker::PhantomData,
            __unsafe_private_named: self.__unsafe_private_named,
            _phantom: ::core::marker::PhantomData,
        }
    }
}

impl<'a, S> EditorBuilder<'a, S>
where
    S: editor_state::State,
    S::Uri: editor_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Editor<'a> {
        Editor {
            uri: self.__unsafe_private_named.0.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: std::collections::BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> Editor<'a> {
        Editor {
            uri: self.__unsafe_private_named.0.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

#[jacquard_derive::lexicon]
#[derive(
    serde::Serialize,
    serde::Deserialize,
    Debug,
    Clone,
    PartialEq,
    Eq,
    jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct EditorOutput<'a> {
    #[serde(flatten)]
    #[serde(borrow)]
    pub value: crate::at_inlay::Response<'a>,
}

/// Response type for
///org.atsui.Editor
pub struct EditorResponse;
impl jacquard_common::xrpc::XrpcResp for EditorResponse {
    const NSID: &'static str = "org.atsui.Editor";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = EditorOutput<'de>;
    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}

impl<'a> jacquard_common::xrpc::XrpcRequest for Editor<'a> {
    const NSID: &'static str = "org.atsui.Editor";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
        "application/json",
    );
    type Response = EditorResponse;
}

/// Endpoint type for
///org.atsui.Editor
pub struct EditorRequest;
impl jacquard_common::xrpc::XrpcEndpoint for EditorRequest {
    const PATH: &'static str = "/xrpc/org.atsui.Editor";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
        "application/json",
    );
    type Request<'de> = Editor<'de>;
    type Response = EditorResponse;
}