#[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::value::Data;
use jacquard_derive::IntoStatic;
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct UpdateAllRead<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<UpdateAllReadStatus<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 UpdateAllReadStatus<S: BosStr = DefaultStr> {
Request,
Accepted,
Other(S),
}
impl<S: BosStr> UpdateAllReadStatus<S> {
pub fn as_str(&self) -> &str {
match self {
Self::Request => "request",
Self::Accepted => "accepted",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"request" => Self::Request,
"accepted" => Self::Accepted,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for UpdateAllReadStatus<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for UpdateAllReadStatus<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for UpdateAllReadStatus<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 UpdateAllReadStatus<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 UpdateAllReadStatus<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for UpdateAllReadStatus<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = UpdateAllReadStatus<S::Output>;
fn into_static(self) -> Self::Output {
match self {
UpdateAllReadStatus::Request => UpdateAllReadStatus::Request,
UpdateAllReadStatus::Accepted => UpdateAllReadStatus::Accepted,
UpdateAllReadStatus::Other(v) => UpdateAllReadStatus::Other(v.into_static()),
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct UpdateAllReadOutput<S: BosStr = DefaultStr> {
pub updated_count: i64,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
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<S: BosStr> = UpdateAllReadOutput<S>;
type Err = jacquard_common::xrpc::GenericError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for UpdateAllRead<S> {
const NSID: &'static str = "chat.bsky.convo.updateAllRead";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Response = UpdateAllReadResponse;
}
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<S: BosStr> = UpdateAllRead<S>;
type Response = UpdateAllReadResponse;
}