#[allow(unused_imports)]
use alloc::collections::BTreeMap;
use crate::at_inlay::Response;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::Datetime;
use jacquard_common::types::value::Data;
use jacquard_common::{BosStr, DefaultStr, FromStaticStr};
use jacquard_derive::IntoStatic;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Timestamp<S: BosStr = DefaultStr> {
pub value: Datetime,
#[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)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct TimestampOutput<S: BosStr = DefaultStr> {
#[serde(flatten)]
pub value: Response<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
pub struct TimestampResponse;
impl jacquard_common::xrpc::XrpcResp for TimestampResponse {
const NSID: &'static str = "org.atsui.Timestamp";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = TimestampOutput<S>;
type Err = jacquard_common::xrpc::GenericError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for Timestamp<S> {
const NSID: &'static str = "org.atsui.Timestamp";
const METHOD: jacquard_common::xrpc::XrpcMethod =
jacquard_common::xrpc::XrpcMethod::Procedure("application/json");
type Response = TimestampResponse;
}
pub struct TimestampRequest;
impl jacquard_common::xrpc::XrpcEndpoint for TimestampRequest {
const PATH: &'static str = "/xrpc/org.atsui.Timestamp";
const METHOD: jacquard_common::xrpc::XrpcMethod =
jacquard_common::xrpc::XrpcMethod::Procedure("application/json");
type Request<S: BosStr> = Timestamp<S>;
type Response = TimestampResponse;
}
pub mod timestamp_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Value;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Value = Unset;
}
pub struct SetValue<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetValue<St> {}
impl<St: State> State for SetValue<St> {
type Value = Set<members::value>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct value(());
}
}
pub struct TimestampBuilder<S: BosStr, St: timestamp_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Datetime>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Timestamp<S> {
pub fn new() -> TimestampBuilder<S, timestamp_state::Empty> {
TimestampBuilder::new()
}
}
impl<S: BosStr> TimestampBuilder<S, timestamp_state::Empty> {
pub fn new() -> Self {
TimestampBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> TimestampBuilder<S, St>
where
St: timestamp_state::State,
St::Value: timestamp_state::IsUnset,
{
pub fn value(
mut self,
value: impl Into<Datetime>,
) -> TimestampBuilder<S, timestamp_state::SetValue<St>> {
self._fields.0 = Option::Some(value.into());
TimestampBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> TimestampBuilder<S, St>
where
St: timestamp_state::State,
St::Value: timestamp_state::IsSet,
{
pub fn build(self) -> Timestamp<S> {
Timestamp {
value: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Timestamp<S> {
Timestamp {
value: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}