jacquard-api 0.11.1

Generated AT Protocol API bindings for Jacquard
Documentation
// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: sh.weaver.notification.getUnreadCount
//
// 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::types::string::Datetime;
use jacquard_derive::{IntoStatic, lexicon};
use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetUnreadCount {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub seen_at: Option<Datetime>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetUnreadCountOutput<'a> {
    pub count: i64,
}

/// Response type for sh.weaver.notification.getUnreadCount
pub struct GetUnreadCountResponse;
impl jacquard_common::xrpc::XrpcResp for GetUnreadCountResponse {
    const NSID: &'static str = "sh.weaver.notification.getUnreadCount";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = GetUnreadCountOutput<'de>;
    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}

impl jacquard_common::xrpc::XrpcRequest for GetUnreadCount {
    const NSID: &'static str = "sh.weaver.notification.getUnreadCount";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = GetUnreadCountResponse;
}

/// Endpoint type for sh.weaver.notification.getUnreadCount
pub struct GetUnreadCountRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetUnreadCountRequest {
    const PATH: &'static str = "/xrpc/sh.weaver.notification.getUnreadCount";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<'de> = GetUnreadCount;
    type Response = GetUnreadCountResponse;
}

pub mod get_unread_count_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {}
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {}
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {}
}

/// Builder for constructing an instance of this type
pub struct GetUnreadCountBuilder<S: get_unread_count_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<Datetime>,),
}

impl GetUnreadCount {
    /// Create a new builder for this type
    pub fn new() -> GetUnreadCountBuilder<get_unread_count_state::Empty> {
        GetUnreadCountBuilder::new()
    }
}

impl GetUnreadCountBuilder<get_unread_count_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        GetUnreadCountBuilder {
            _state: PhantomData,
            _fields: (None,),
        }
    }
}

impl<S: get_unread_count_state::State> GetUnreadCountBuilder<S> {
    /// Set the `seenAt` field (optional)
    pub fn seen_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `seenAt` field to an Option value (optional)
    pub fn maybe_seen_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<S> GetUnreadCountBuilder<S>
where
    S: get_unread_count_state::State,
{
    /// Build the final struct
    pub fn build(self) -> GetUnreadCount {
        GetUnreadCount {
            seen_at: self._fields.0,
        }
    }
}