// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: space.polymodel.actor.bootstrapProfile
//
// 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, BosStr, DefaultStr, FromStaticStr};
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::{AtUri, Cid};
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
use serde::{Serialize, Deserialize};
use crate::space_polymodel::actor::ProfileView;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct BootstrapProfileOutput<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cid: Option<Cid<S>>,
    pub profile: ProfileView<S>,
    pub status: BootstrapProfileOutputStatus<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub uri: Option<AtUri<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum BootstrapProfileOutputStatus<S: BosStr = DefaultStr> {
    ExistingLocal,
    ExistingRemote,
    Created,
    Other(S),
}

impl<S: BosStr> BootstrapProfileOutputStatus<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::ExistingLocal => "existingLocal",
            Self::ExistingRemote => "existingRemote",
            Self::Created => "created",
            Self::Other(s) => s.as_ref(),
        }
    }
    /// Construct from a string-like value, matching known values.
    pub fn from_value(s: S) -> Self {
        match s.as_ref() {
            "existingLocal" => Self::ExistingLocal,
            "existingRemote" => Self::ExistingRemote,
            "created" => Self::Created,
            _ => Self::Other(s),
        }
    }
}

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

impl<S: BosStr> AsRef<str> for BootstrapProfileOutputStatus<S> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

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

impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de>
for BootstrapProfileOutputStatus<S> {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = S::deserialize(deserializer)?;
        Ok(Self::from_value(s))
    }
}

impl<S: BosStr + Default> Default for BootstrapProfileOutputStatus<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for BootstrapProfileOutputStatus<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = BootstrapProfileOutputStatus<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            BootstrapProfileOutputStatus::ExistingLocal => {
                BootstrapProfileOutputStatus::ExistingLocal
            }
            BootstrapProfileOutputStatus::ExistingRemote => {
                BootstrapProfileOutputStatus::ExistingRemote
            }
            BootstrapProfileOutputStatus::Created => {
                BootstrapProfileOutputStatus::Created
            }
            BootstrapProfileOutputStatus::Other(v) => {
                BootstrapProfileOutputStatus::Other(v.into_static())
            }
        }
    }
}

/** Request marker for the `space.polymodel.actor.bootstrapProfile` procedure.

This endpoint has no request parameters or input body; send this marker with `jacquard::Client`.*/

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Copy)]
pub struct BootstrapProfile;
/** Response marker for the `space.polymodel.actor.bootstrapProfile` procedure.

Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `BootstrapProfileOutput<S>` for this endpoint.*/
pub struct BootstrapProfileResponse;
impl jacquard_common::xrpc::XrpcResp for BootstrapProfileResponse {
    const NSID: &'static str = "space.polymodel.actor.bootstrapProfile";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = BootstrapProfileOutput<S>;
    type Err = jacquard_common::xrpc::GenericError;
}

impl jacquard_common::xrpc::XrpcRequest for BootstrapProfile {
    const NSID: &'static str = "space.polymodel.actor.bootstrapProfile";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
        "application/json",
    );
    type Response = BootstrapProfileResponse;
}

/** Endpoint marker for the `space.polymodel.actor.bootstrapProfile` procedure.

Path: `/xrpc/space.polymodel.actor.bootstrapProfile`. The request payload type is `BootstrapProfile`; use this marker with lower-level `XrpcEndpoint` APIs when you need endpoint metadata.*/
pub struct BootstrapProfileRequest;
impl jacquard_common::xrpc::XrpcEndpoint for BootstrapProfileRequest {
    const PATH: &'static str = "/xrpc/space.polymodel.actor.bootstrapProfile";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
        "application/json",
    );
    type Request<S: BosStr> = BootstrapProfile;
    type Response = BootstrapProfileResponse;
}