#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{BosStr, DefaultStr, FromStaticStr};
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::AtUri;
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct NotifyOfNewEntry<S: BosStr = DefaultStr> {
pub entry_uri: AtUri<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct NotifyOfNewEntryOutput<S: BosStr = DefaultStr> {
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(
Serialize,
Deserialize,
Debug,
Clone,
PartialEq,
Eq,
thiserror::Error,
miette::Diagnostic
)]
#[serde(tag = "error", content = "message")]
pub enum NotifyOfNewEntryError {
#[serde(untagged)]
Other { error: SmolStr, message: Option<SmolStr> },
}
impl core::fmt::Display for NotifyOfNewEntryError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::Other { error, message } => {
write!(f, "{}", error)?;
if let Some(msg) = message {
write!(f, ": {}", msg)?;
}
Ok(())
}
}
}
}
pub struct NotifyOfNewEntryResponse;
impl jacquard_common::xrpc::XrpcResp for NotifyOfNewEntryResponse {
const NSID: &'static str = "com.whtwnd.blog.notifyOfNewEntry";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = NotifyOfNewEntryOutput<S>;
type Err = NotifyOfNewEntryError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for NotifyOfNewEntry<S> {
const NSID: &'static str = "com.whtwnd.blog.notifyOfNewEntry";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Response = NotifyOfNewEntryResponse;
}
pub struct NotifyOfNewEntryRequest;
impl jacquard_common::xrpc::XrpcEndpoint for NotifyOfNewEntryRequest {
const PATH: &'static str = "/xrpc/com.whtwnd.blog.notifyOfNewEntry";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Request<S: BosStr> = NotifyOfNewEntry<S>;
type Response = NotifyOfNewEntryResponse;
}
pub mod notify_of_new_entry_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type EntryUri;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type EntryUri = Unset;
}
pub struct SetEntryUri<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetEntryUri<St> {}
impl<St: State> State for SetEntryUri<St> {
type EntryUri = Set<members::entry_uri>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct entry_uri(());
}
}
pub struct NotifyOfNewEntryBuilder<S: BosStr, St: notify_of_new_entry_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<AtUri<S>>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> NotifyOfNewEntry<S> {
pub fn new() -> NotifyOfNewEntryBuilder<S, notify_of_new_entry_state::Empty> {
NotifyOfNewEntryBuilder::new()
}
}
impl<S: BosStr> NotifyOfNewEntryBuilder<S, notify_of_new_entry_state::Empty> {
pub fn new() -> Self {
NotifyOfNewEntryBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> NotifyOfNewEntryBuilder<S, St>
where
St: notify_of_new_entry_state::State,
St::EntryUri: notify_of_new_entry_state::IsUnset,
{
pub fn entry_uri(
mut self,
value: impl Into<AtUri<S>>,
) -> NotifyOfNewEntryBuilder<S, notify_of_new_entry_state::SetEntryUri<St>> {
self._fields.0 = Option::Some(value.into());
NotifyOfNewEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> NotifyOfNewEntryBuilder<S, St>
where
St: notify_of_new_entry_state::State,
St::EntryUri: notify_of_new_entry_state::IsSet,
{
pub fn build(self) -> NotifyOfNewEntry<S> {
NotifyOfNewEntry {
entry_uri: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> NotifyOfNewEntry<S> {
NotifyOfNewEntry {
entry_uri: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}