jacquard-api 0.11.1

Generated AT Protocol API bindings for Jacquard
Documentation
// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: chat.bsky.convo.updateAllRead
//
// 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};

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


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum UpdateAllReadStatus<'a> {
    Request,
    Accepted,
    Other(CowStr<'a>),
}

impl<'a> UpdateAllReadStatus<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Request => "request",
            Self::Accepted => "accepted",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for UpdateAllReadStatus<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "request" => Self::Request,
            "accepted" => Self::Accepted,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for UpdateAllReadStatus<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "request" => Self::Request,
            "accepted" => Self::Accepted,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

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

impl<'a> serde::Serialize for UpdateAllReadStatus<'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 UpdateAllReadStatus<'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 UpdateAllReadStatus<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

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


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct UpdateAllReadOutput<'a> {
    ///The count of updated convos.
    pub updated_count: i64,
}

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

impl<'a> jacquard_common::xrpc::XrpcRequest for UpdateAllRead<'a> {
    const NSID: &'static str = "chat.bsky.convo.updateAllRead";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
        "application/json",
    );
    type Response = UpdateAllReadResponse;
}

/// Endpoint type for chat.bsky.convo.updateAllRead
pub struct UpdateAllReadRequest;
impl jacquard_common::xrpc::XrpcEndpoint for UpdateAllReadRequest {
    const PATH: &'static str = "/xrpc/chat.bsky.convo.updateAllRead";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
        "application/json",
    );
    type Request<'de> = UpdateAllRead<'de>;
    type Response = UpdateAllReadResponse;
}