// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: tools.ozone.setting.removeOptions
//
// 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::Nsid;
use jacquard_derive::{IntoStatic, lexicon};
use serde::{Serialize, Deserialize};

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct RemoveOptions<'a> {
    #[serde(borrow)]
    pub keys: Vec<Nsid<'a>>,
    #[serde(borrow)]
    pub scope: RemoveOptionsScope<'a>,
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum RemoveOptionsScope<'a> {
    Instance,
    Personal,
    Other(CowStr<'a>),
}

impl<'a> RemoveOptionsScope<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Instance => "instance",
            Self::Personal => "personal",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for RemoveOptionsScope<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "instance" => Self::Instance,
            "personal" => Self::Personal,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for RemoveOptionsScope<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "instance" => Self::Instance,
            "personal" => Self::Personal,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> core::fmt::Display for RemoveOptionsScope<'a> {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "{}", self.as_str())
    }
}

impl<'a> AsRef<str> for RemoveOptionsScope<'a> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl<'a> serde::Serialize for RemoveOptionsScope<'a> {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, 'a> serde::Deserialize<'de> for RemoveOptionsScope<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl<'a> Default for RemoveOptionsScope<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for RemoveOptionsScope<'_> {
    type Output = RemoveOptionsScope<'static>;
    fn into_static(self) -> Self::Output {
        match self {
            RemoveOptionsScope::Instance => RemoveOptionsScope::Instance,
            RemoveOptionsScope::Personal => RemoveOptionsScope::Personal,
            RemoveOptionsScope::Other(v) => RemoveOptionsScope::Other(v.into_static()),
        }
    }
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct RemoveOptionsOutput<'a> {}
/// Response type for tools.ozone.setting.removeOptions
pub struct RemoveOptionsResponse;
impl jacquard_common::xrpc::XrpcResp for RemoveOptionsResponse {
    const NSID: &'static str = "tools.ozone.setting.removeOptions";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = RemoveOptionsOutput<'de>;
    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}

impl<'a> jacquard_common::xrpc::XrpcRequest for RemoveOptions<'a> {
    const NSID: &'static str = "tools.ozone.setting.removeOptions";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
        "application/json",
    );
    type Response = RemoveOptionsResponse;
}

/// Endpoint type for tools.ozone.setting.removeOptions
pub struct RemoveOptionsRequest;
impl jacquard_common::xrpc::XrpcEndpoint for RemoveOptionsRequest {
    const PATH: &'static str = "/xrpc/tools.ozone.setting.removeOptions";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
        "application/json",
    );
    type Request<'de> = RemoveOptions<'de>;
    type Response = RemoveOptionsResponse;
}

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

/// Builder for constructing an instance of this type
pub struct RemoveOptionsBuilder<'a, S: remove_options_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<Vec<Nsid<'a>>>, Option<RemoveOptionsScope<'a>>),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> RemoveOptions<'a> {
    /// Create a new builder for this type
    pub fn new() -> RemoveOptionsBuilder<'a, remove_options_state::Empty> {
        RemoveOptionsBuilder::new()
    }
}

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

impl<'a, S> RemoveOptionsBuilder<'a, S>
where
    S: remove_options_state::State,
    S::Keys: remove_options_state::IsUnset,
{
    /// Set the `keys` field (required)
    pub fn keys(
        mut self,
        value: impl Into<Vec<Nsid<'a>>>,
    ) -> RemoveOptionsBuilder<'a, remove_options_state::SetKeys<S>> {
        self._fields.0 = Option::Some(value.into());
        RemoveOptionsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> RemoveOptionsBuilder<'a, S>
where
    S: remove_options_state::State,
    S::Scope: remove_options_state::IsUnset,
{
    /// Set the `scope` field (required)
    pub fn scope(
        mut self,
        value: impl Into<RemoveOptionsScope<'a>>,
    ) -> RemoveOptionsBuilder<'a, remove_options_state::SetScope<S>> {
        self._fields.1 = Option::Some(value.into());
        RemoveOptionsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> RemoveOptionsBuilder<'a, S>
where
    S: remove_options_state::State,
    S::Scope: remove_options_state::IsSet,
    S::Keys: remove_options_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> RemoveOptions<'a> {
        RemoveOptions {
            keys: self._fields.0.unwrap(),
            scope: self._fields.1.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> RemoveOptions<'a> {
        RemoveOptions {
            keys: self._fields.0.unwrap(),
            scope: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}