#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::Datetime;
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::app_chronosky::plan::get_usage;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct CurrentPlan<'a> {
#[serde(borrow)]
pub display_name: Data<'a>,
#[serde(borrow)]
pub id: CowStr<'a>,
pub is_active: bool,
#[serde(borrow)]
pub name: CowStr<'a>,
#[serde(borrow)]
pub tier: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
pub valid_until: Option<Datetime>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetUsageOutput<'a> {
#[serde(borrow)]
pub current_plan: get_usage::CurrentPlan<'a>,
#[serde(borrow)]
pub limits: get_usage::PlanLimits<'a>,
#[serde(borrow)]
pub usage: get_usage::UsageStats<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct PlanLimits<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
pub markdown_support: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_image_size_mb: Option<i64>,
pub max_images_per_post: i64,
pub max_schedule_days: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_video_size_mb: Option<i64>,
pub monthly_posts_limit: i64,
pub pending_posts_limit: i64,
pub schedule_interval_minutes: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub thread_posts: Option<bool>,
pub thread_posts_limit: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub video_processing_minutes_monthly: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub video_upload: Option<bool>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct UsageStats<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
pub api_requests_this_hour: Option<i64>,
pub last_updated: Datetime,
pub monthly_period_end: Datetime,
pub monthly_period_start: Datetime,
pub monthly_posts_count: i64,
pub pending_posts_count: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub storage_used_mb: Option<i64>,
}
impl<'a> LexiconSchema for CurrentPlan<'a> {
fn nsid() -> &'static str {
"app.chronosky.plan.getUsage"
}
fn def_name() -> &'static str {
"currentPlan"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_chronosky_plan_getUsage()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.id;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 100usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("id"),
max: 100usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.name;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 200usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("name"),
max: 200usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.tier;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 50usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("tier"),
max: 50usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Copy)]
pub struct GetUsage;
pub struct GetUsageResponse;
impl jacquard_common::xrpc::XrpcResp for GetUsageResponse {
const NSID: &'static str = "app.chronosky.plan.getUsage";
const ENCODING: &'static str = "application/json";
type Output<'de> = GetUsageOutput<'de>;
type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}
impl jacquard_common::xrpc::XrpcRequest for GetUsage {
const NSID: &'static str = "app.chronosky.plan.getUsage";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Response = GetUsageResponse;
}
pub struct GetUsageRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetUsageRequest {
const PATH: &'static str = "/xrpc/app.chronosky.plan.getUsage";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Request<'de> = GetUsage;
type Response = GetUsageResponse;
}
impl<'a> LexiconSchema for PlanLimits<'a> {
fn nsid() -> &'static str {
"app.chronosky.plan.getUsage"
}
fn def_name() -> &'static str {
"planLimits"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_chronosky_plan_getUsage()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for UsageStats<'a> {
fn nsid() -> &'static str {
"app.chronosky.plan.getUsage"
}
fn def_name() -> &'static str {
"usageStats"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_chronosky_plan_getUsage()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod current_plan_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 Id;
type IsActive;
type Tier;
type Name;
type DisplayName;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Id = Unset;
type IsActive = Unset;
type Tier = Unset;
type Name = Unset;
type DisplayName = Unset;
}
pub struct SetId<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetId<S> {}
impl<S: State> State for SetId<S> {
type Id = Set<members::id>;
type IsActive = S::IsActive;
type Tier = S::Tier;
type Name = S::Name;
type DisplayName = S::DisplayName;
}
pub struct SetIsActive<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetIsActive<S> {}
impl<S: State> State for SetIsActive<S> {
type Id = S::Id;
type IsActive = Set<members::is_active>;
type Tier = S::Tier;
type Name = S::Name;
type DisplayName = S::DisplayName;
}
pub struct SetTier<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetTier<S> {}
impl<S: State> State for SetTier<S> {
type Id = S::Id;
type IsActive = S::IsActive;
type Tier = Set<members::tier>;
type Name = S::Name;
type DisplayName = S::DisplayName;
}
pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetName<S> {}
impl<S: State> State for SetName<S> {
type Id = S::Id;
type IsActive = S::IsActive;
type Tier = S::Tier;
type Name = Set<members::name>;
type DisplayName = S::DisplayName;
}
pub struct SetDisplayName<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetDisplayName<S> {}
impl<S: State> State for SetDisplayName<S> {
type Id = S::Id;
type IsActive = S::IsActive;
type Tier = S::Tier;
type Name = S::Name;
type DisplayName = Set<members::display_name>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct id(());
pub struct is_active(());
pub struct tier(());
pub struct name(());
pub struct display_name(());
}
}
pub struct CurrentPlanBuilder<'a, S: current_plan_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<Data<'a>>,
Option<CowStr<'a>>,
Option<bool>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<Datetime>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> CurrentPlan<'a> {
pub fn new() -> CurrentPlanBuilder<'a, current_plan_state::Empty> {
CurrentPlanBuilder::new()
}
}
impl<'a> CurrentPlanBuilder<'a, current_plan_state::Empty> {
pub fn new() -> Self {
CurrentPlanBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> CurrentPlanBuilder<'a, S>
where
S: current_plan_state::State,
S::DisplayName: current_plan_state::IsUnset,
{
pub fn display_name(
mut self,
value: impl Into<Data<'a>>,
) -> CurrentPlanBuilder<'a, current_plan_state::SetDisplayName<S>> {
self._fields.0 = Option::Some(value.into());
CurrentPlanBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> CurrentPlanBuilder<'a, S>
where
S: current_plan_state::State,
S::Id: current_plan_state::IsUnset,
{
pub fn id(
mut self,
value: impl Into<CowStr<'a>>,
) -> CurrentPlanBuilder<'a, current_plan_state::SetId<S>> {
self._fields.1 = Option::Some(value.into());
CurrentPlanBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> CurrentPlanBuilder<'a, S>
where
S: current_plan_state::State,
S::IsActive: current_plan_state::IsUnset,
{
pub fn is_active(
mut self,
value: impl Into<bool>,
) -> CurrentPlanBuilder<'a, current_plan_state::SetIsActive<S>> {
self._fields.2 = Option::Some(value.into());
CurrentPlanBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> CurrentPlanBuilder<'a, S>
where
S: current_plan_state::State,
S::Name: current_plan_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<CowStr<'a>>,
) -> CurrentPlanBuilder<'a, current_plan_state::SetName<S>> {
self._fields.3 = Option::Some(value.into());
CurrentPlanBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> CurrentPlanBuilder<'a, S>
where
S: current_plan_state::State,
S::Tier: current_plan_state::IsUnset,
{
pub fn tier(
mut self,
value: impl Into<CowStr<'a>>,
) -> CurrentPlanBuilder<'a, current_plan_state::SetTier<S>> {
self._fields.4 = Option::Some(value.into());
CurrentPlanBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: current_plan_state::State> CurrentPlanBuilder<'a, S> {
pub fn valid_until(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_valid_until(mut self, value: Option<Datetime>) -> Self {
self._fields.5 = value;
self
}
}
impl<'a, S> CurrentPlanBuilder<'a, S>
where
S: current_plan_state::State,
S::Id: current_plan_state::IsSet,
S::IsActive: current_plan_state::IsSet,
S::Tier: current_plan_state::IsSet,
S::Name: current_plan_state::IsSet,
S::DisplayName: current_plan_state::IsSet,
{
pub fn build(self) -> CurrentPlan<'a> {
CurrentPlan {
display_name: self._fields.0.unwrap(),
id: self._fields.1.unwrap(),
is_active: self._fields.2.unwrap(),
name: self._fields.3.unwrap(),
tier: self._fields.4.unwrap(),
valid_until: self._fields.5,
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
) -> CurrentPlan<'a> {
CurrentPlan {
display_name: self._fields.0.unwrap(),
id: self._fields.1.unwrap(),
is_active: self._fields.2.unwrap(),
name: self._fields.3.unwrap(),
tier: self._fields.4.unwrap(),
valid_until: self._fields.5,
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_app_chronosky_plan_getUsage() -> LexiconDoc<'static> {
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
use alloc::collections::BTreeMap;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("app.chronosky.plan.getUsage"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("currentPlan"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static("Current plan information.")),
required: Some(
vec![
SmolStr::new_static("id"), SmolStr::new_static("tier"),
SmolStr::new_static("name"),
SmolStr::new_static("displayName"),
SmolStr::new_static("isActive")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("displayName"),
LexObjectProperty::Unknown(LexUnknown {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("id"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Plan ID")),
max_length: Some(100usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("isActive"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Internal plan name")),
max_length: Some(200usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("tier"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Plan tier (FREE, BASIC, STANDARD, PREMIUM)",
),
),
max_length: Some(50usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("validUntil"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Plan expiration date (ISO 8601)"),
),
format: Some(LexStringFormat::Datetime),
max_length: Some(100usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::XrpcQuery(LexXrpcQuery {
parameters: None,
..Default::default()
}),
);
map.insert(
SmolStr::new_static("planLimits"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static("Plan limits.")),
required: Some(
vec![
SmolStr::new_static("monthlyPostsLimit"),
SmolStr::new_static("pendingPostsLimit"),
SmolStr::new_static("maxScheduleDays"),
SmolStr::new_static("scheduleIntervalMinutes"),
SmolStr::new_static("maxImagesPerPost"),
SmolStr::new_static("threadPostsLimit")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("markdownSupport"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("maxImageSizeMb"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("maxImagesPerPost"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("maxScheduleDays"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("maxVideoSizeMb"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("monthlyPostsLimit"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("pendingPostsLimit"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("scheduleIntervalMinutes"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("threadPosts"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("threadPostsLimit"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("videoProcessingMinutesMonthly"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("videoUpload"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("usageStats"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static("Usage statistics.")),
required: Some(
vec![
SmolStr::new_static("pendingPostsCount"),
SmolStr::new_static("monthlyPostsCount"),
SmolStr::new_static("monthlyPeriodStart"),
SmolStr::new_static("monthlyPeriodEnd"),
SmolStr::new_static("lastUpdated")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("apiRequestsThisHour"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("lastUpdated"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Last time usage was updated (ISO 8601)"),
),
format: Some(LexStringFormat::Datetime),
max_length: Some(100usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("monthlyPeriodEnd"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"End of current monthly period (ISO 8601)",
),
),
format: Some(LexStringFormat::Datetime),
max_length: Some(100usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("monthlyPeriodStart"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Start of current monthly period (ISO 8601)",
),
),
format: Some(LexStringFormat::Datetime),
max_length: Some(100usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("monthlyPostsCount"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("pendingPostsCount"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("storageUsedMb"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod plan_limits_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 ThreadPostsLimit;
type PendingPostsLimit;
type MonthlyPostsLimit;
type MaxScheduleDays;
type MaxImagesPerPost;
type ScheduleIntervalMinutes;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type ThreadPostsLimit = Unset;
type PendingPostsLimit = Unset;
type MonthlyPostsLimit = Unset;
type MaxScheduleDays = Unset;
type MaxImagesPerPost = Unset;
type ScheduleIntervalMinutes = Unset;
}
pub struct SetThreadPostsLimit<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetThreadPostsLimit<S> {}
impl<S: State> State for SetThreadPostsLimit<S> {
type ThreadPostsLimit = Set<members::thread_posts_limit>;
type PendingPostsLimit = S::PendingPostsLimit;
type MonthlyPostsLimit = S::MonthlyPostsLimit;
type MaxScheduleDays = S::MaxScheduleDays;
type MaxImagesPerPost = S::MaxImagesPerPost;
type ScheduleIntervalMinutes = S::ScheduleIntervalMinutes;
}
pub struct SetPendingPostsLimit<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetPendingPostsLimit<S> {}
impl<S: State> State for SetPendingPostsLimit<S> {
type ThreadPostsLimit = S::ThreadPostsLimit;
type PendingPostsLimit = Set<members::pending_posts_limit>;
type MonthlyPostsLimit = S::MonthlyPostsLimit;
type MaxScheduleDays = S::MaxScheduleDays;
type MaxImagesPerPost = S::MaxImagesPerPost;
type ScheduleIntervalMinutes = S::ScheduleIntervalMinutes;
}
pub struct SetMonthlyPostsLimit<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetMonthlyPostsLimit<S> {}
impl<S: State> State for SetMonthlyPostsLimit<S> {
type ThreadPostsLimit = S::ThreadPostsLimit;
type PendingPostsLimit = S::PendingPostsLimit;
type MonthlyPostsLimit = Set<members::monthly_posts_limit>;
type MaxScheduleDays = S::MaxScheduleDays;
type MaxImagesPerPost = S::MaxImagesPerPost;
type ScheduleIntervalMinutes = S::ScheduleIntervalMinutes;
}
pub struct SetMaxScheduleDays<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetMaxScheduleDays<S> {}
impl<S: State> State for SetMaxScheduleDays<S> {
type ThreadPostsLimit = S::ThreadPostsLimit;
type PendingPostsLimit = S::PendingPostsLimit;
type MonthlyPostsLimit = S::MonthlyPostsLimit;
type MaxScheduleDays = Set<members::max_schedule_days>;
type MaxImagesPerPost = S::MaxImagesPerPost;
type ScheduleIntervalMinutes = S::ScheduleIntervalMinutes;
}
pub struct SetMaxImagesPerPost<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetMaxImagesPerPost<S> {}
impl<S: State> State for SetMaxImagesPerPost<S> {
type ThreadPostsLimit = S::ThreadPostsLimit;
type PendingPostsLimit = S::PendingPostsLimit;
type MonthlyPostsLimit = S::MonthlyPostsLimit;
type MaxScheduleDays = S::MaxScheduleDays;
type MaxImagesPerPost = Set<members::max_images_per_post>;
type ScheduleIntervalMinutes = S::ScheduleIntervalMinutes;
}
pub struct SetScheduleIntervalMinutes<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetScheduleIntervalMinutes<S> {}
impl<S: State> State for SetScheduleIntervalMinutes<S> {
type ThreadPostsLimit = S::ThreadPostsLimit;
type PendingPostsLimit = S::PendingPostsLimit;
type MonthlyPostsLimit = S::MonthlyPostsLimit;
type MaxScheduleDays = S::MaxScheduleDays;
type MaxImagesPerPost = S::MaxImagesPerPost;
type ScheduleIntervalMinutes = Set<members::schedule_interval_minutes>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct thread_posts_limit(());
pub struct pending_posts_limit(());
pub struct monthly_posts_limit(());
pub struct max_schedule_days(());
pub struct max_images_per_post(());
pub struct schedule_interval_minutes(());
}
}
pub struct PlanLimitsBuilder<'a, S: plan_limits_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<bool>,
Option<i64>,
Option<i64>,
Option<i64>,
Option<i64>,
Option<i64>,
Option<i64>,
Option<i64>,
Option<bool>,
Option<i64>,
Option<i64>,
Option<bool>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> PlanLimits<'a> {
pub fn new() -> PlanLimitsBuilder<'a, plan_limits_state::Empty> {
PlanLimitsBuilder::new()
}
}
impl<'a> PlanLimitsBuilder<'a, plan_limits_state::Empty> {
pub fn new() -> Self {
PlanLimitsBuilder {
_state: PhantomData,
_fields: (
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
),
_lifetime: PhantomData,
}
}
}
impl<'a, S: plan_limits_state::State> PlanLimitsBuilder<'a, S> {
pub fn markdown_support(mut self, value: impl Into<Option<bool>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_markdown_support(mut self, value: Option<bool>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S: plan_limits_state::State> PlanLimitsBuilder<'a, S> {
pub fn max_image_size_mb(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_max_image_size_mb(mut self, value: Option<i64>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S> PlanLimitsBuilder<'a, S>
where
S: plan_limits_state::State,
S::MaxImagesPerPost: plan_limits_state::IsUnset,
{
pub fn max_images_per_post(
mut self,
value: impl Into<i64>,
) -> PlanLimitsBuilder<'a, plan_limits_state::SetMaxImagesPerPost<S>> {
self._fields.2 = Option::Some(value.into());
PlanLimitsBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> PlanLimitsBuilder<'a, S>
where
S: plan_limits_state::State,
S::MaxScheduleDays: plan_limits_state::IsUnset,
{
pub fn max_schedule_days(
mut self,
value: impl Into<i64>,
) -> PlanLimitsBuilder<'a, plan_limits_state::SetMaxScheduleDays<S>> {
self._fields.3 = Option::Some(value.into());
PlanLimitsBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: plan_limits_state::State> PlanLimitsBuilder<'a, S> {
pub fn max_video_size_mb(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_max_video_size_mb(mut self, value: Option<i64>) -> Self {
self._fields.4 = value;
self
}
}
impl<'a, S> PlanLimitsBuilder<'a, S>
where
S: plan_limits_state::State,
S::MonthlyPostsLimit: plan_limits_state::IsUnset,
{
pub fn monthly_posts_limit(
mut self,
value: impl Into<i64>,
) -> PlanLimitsBuilder<'a, plan_limits_state::SetMonthlyPostsLimit<S>> {
self._fields.5 = Option::Some(value.into());
PlanLimitsBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> PlanLimitsBuilder<'a, S>
where
S: plan_limits_state::State,
S::PendingPostsLimit: plan_limits_state::IsUnset,
{
pub fn pending_posts_limit(
mut self,
value: impl Into<i64>,
) -> PlanLimitsBuilder<'a, plan_limits_state::SetPendingPostsLimit<S>> {
self._fields.6 = Option::Some(value.into());
PlanLimitsBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> PlanLimitsBuilder<'a, S>
where
S: plan_limits_state::State,
S::ScheduleIntervalMinutes: plan_limits_state::IsUnset,
{
pub fn schedule_interval_minutes(
mut self,
value: impl Into<i64>,
) -> PlanLimitsBuilder<'a, plan_limits_state::SetScheduleIntervalMinutes<S>> {
self._fields.7 = Option::Some(value.into());
PlanLimitsBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: plan_limits_state::State> PlanLimitsBuilder<'a, S> {
pub fn thread_posts(mut self, value: impl Into<Option<bool>>) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_thread_posts(mut self, value: Option<bool>) -> Self {
self._fields.8 = value;
self
}
}
impl<'a, S> PlanLimitsBuilder<'a, S>
where
S: plan_limits_state::State,
S::ThreadPostsLimit: plan_limits_state::IsUnset,
{
pub fn thread_posts_limit(
mut self,
value: impl Into<i64>,
) -> PlanLimitsBuilder<'a, plan_limits_state::SetThreadPostsLimit<S>> {
self._fields.9 = Option::Some(value.into());
PlanLimitsBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: plan_limits_state::State> PlanLimitsBuilder<'a, S> {
pub fn video_processing_minutes_monthly(
mut self,
value: impl Into<Option<i64>>,
) -> Self {
self._fields.10 = value.into();
self
}
pub fn maybe_video_processing_minutes_monthly(mut self, value: Option<i64>) -> Self {
self._fields.10 = value;
self
}
}
impl<'a, S: plan_limits_state::State> PlanLimitsBuilder<'a, S> {
pub fn video_upload(mut self, value: impl Into<Option<bool>>) -> Self {
self._fields.11 = value.into();
self
}
pub fn maybe_video_upload(mut self, value: Option<bool>) -> Self {
self._fields.11 = value;
self
}
}
impl<'a, S> PlanLimitsBuilder<'a, S>
where
S: plan_limits_state::State,
S::ThreadPostsLimit: plan_limits_state::IsSet,
S::PendingPostsLimit: plan_limits_state::IsSet,
S::MonthlyPostsLimit: plan_limits_state::IsSet,
S::MaxScheduleDays: plan_limits_state::IsSet,
S::MaxImagesPerPost: plan_limits_state::IsSet,
S::ScheduleIntervalMinutes: plan_limits_state::IsSet,
{
pub fn build(self) -> PlanLimits<'a> {
PlanLimits {
markdown_support: self._fields.0,
max_image_size_mb: self._fields.1,
max_images_per_post: self._fields.2.unwrap(),
max_schedule_days: self._fields.3.unwrap(),
max_video_size_mb: self._fields.4,
monthly_posts_limit: self._fields.5.unwrap(),
pending_posts_limit: self._fields.6.unwrap(),
schedule_interval_minutes: self._fields.7.unwrap(),
thread_posts: self._fields.8,
thread_posts_limit: self._fields.9.unwrap(),
video_processing_minutes_monthly: self._fields.10,
video_upload: self._fields.11,
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
) -> PlanLimits<'a> {
PlanLimits {
markdown_support: self._fields.0,
max_image_size_mb: self._fields.1,
max_images_per_post: self._fields.2.unwrap(),
max_schedule_days: self._fields.3.unwrap(),
max_video_size_mb: self._fields.4,
monthly_posts_limit: self._fields.5.unwrap(),
pending_posts_limit: self._fields.6.unwrap(),
schedule_interval_minutes: self._fields.7.unwrap(),
thread_posts: self._fields.8,
thread_posts_limit: self._fields.9.unwrap(),
video_processing_minutes_monthly: self._fields.10,
video_upload: self._fields.11,
extra_data: Some(extra_data),
}
}
}
pub mod usage_stats_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 PendingPostsCount;
type LastUpdated;
type MonthlyPeriodEnd;
type MonthlyPostsCount;
type MonthlyPeriodStart;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type PendingPostsCount = Unset;
type LastUpdated = Unset;
type MonthlyPeriodEnd = Unset;
type MonthlyPostsCount = Unset;
type MonthlyPeriodStart = Unset;
}
pub struct SetPendingPostsCount<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetPendingPostsCount<S> {}
impl<S: State> State for SetPendingPostsCount<S> {
type PendingPostsCount = Set<members::pending_posts_count>;
type LastUpdated = S::LastUpdated;
type MonthlyPeriodEnd = S::MonthlyPeriodEnd;
type MonthlyPostsCount = S::MonthlyPostsCount;
type MonthlyPeriodStart = S::MonthlyPeriodStart;
}
pub struct SetLastUpdated<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetLastUpdated<S> {}
impl<S: State> State for SetLastUpdated<S> {
type PendingPostsCount = S::PendingPostsCount;
type LastUpdated = Set<members::last_updated>;
type MonthlyPeriodEnd = S::MonthlyPeriodEnd;
type MonthlyPostsCount = S::MonthlyPostsCount;
type MonthlyPeriodStart = S::MonthlyPeriodStart;
}
pub struct SetMonthlyPeriodEnd<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetMonthlyPeriodEnd<S> {}
impl<S: State> State for SetMonthlyPeriodEnd<S> {
type PendingPostsCount = S::PendingPostsCount;
type LastUpdated = S::LastUpdated;
type MonthlyPeriodEnd = Set<members::monthly_period_end>;
type MonthlyPostsCount = S::MonthlyPostsCount;
type MonthlyPeriodStart = S::MonthlyPeriodStart;
}
pub struct SetMonthlyPostsCount<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetMonthlyPostsCount<S> {}
impl<S: State> State for SetMonthlyPostsCount<S> {
type PendingPostsCount = S::PendingPostsCount;
type LastUpdated = S::LastUpdated;
type MonthlyPeriodEnd = S::MonthlyPeriodEnd;
type MonthlyPostsCount = Set<members::monthly_posts_count>;
type MonthlyPeriodStart = S::MonthlyPeriodStart;
}
pub struct SetMonthlyPeriodStart<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetMonthlyPeriodStart<S> {}
impl<S: State> State for SetMonthlyPeriodStart<S> {
type PendingPostsCount = S::PendingPostsCount;
type LastUpdated = S::LastUpdated;
type MonthlyPeriodEnd = S::MonthlyPeriodEnd;
type MonthlyPostsCount = S::MonthlyPostsCount;
type MonthlyPeriodStart = Set<members::monthly_period_start>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct pending_posts_count(());
pub struct last_updated(());
pub struct monthly_period_end(());
pub struct monthly_posts_count(());
pub struct monthly_period_start(());
}
}
pub struct UsageStatsBuilder<'a, S: usage_stats_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<i64>,
Option<Datetime>,
Option<Datetime>,
Option<Datetime>,
Option<i64>,
Option<i64>,
Option<i64>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> UsageStats<'a> {
pub fn new() -> UsageStatsBuilder<'a, usage_stats_state::Empty> {
UsageStatsBuilder::new()
}
}
impl<'a> UsageStatsBuilder<'a, usage_stats_state::Empty> {
pub fn new() -> Self {
UsageStatsBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: usage_stats_state::State> UsageStatsBuilder<'a, S> {
pub fn api_requests_this_hour(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_api_requests_this_hour(mut self, value: Option<i64>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S> UsageStatsBuilder<'a, S>
where
S: usage_stats_state::State,
S::LastUpdated: usage_stats_state::IsUnset,
{
pub fn last_updated(
mut self,
value: impl Into<Datetime>,
) -> UsageStatsBuilder<'a, usage_stats_state::SetLastUpdated<S>> {
self._fields.1 = Option::Some(value.into());
UsageStatsBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> UsageStatsBuilder<'a, S>
where
S: usage_stats_state::State,
S::MonthlyPeriodEnd: usage_stats_state::IsUnset,
{
pub fn monthly_period_end(
mut self,
value: impl Into<Datetime>,
) -> UsageStatsBuilder<'a, usage_stats_state::SetMonthlyPeriodEnd<S>> {
self._fields.2 = Option::Some(value.into());
UsageStatsBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> UsageStatsBuilder<'a, S>
where
S: usage_stats_state::State,
S::MonthlyPeriodStart: usage_stats_state::IsUnset,
{
pub fn monthly_period_start(
mut self,
value: impl Into<Datetime>,
) -> UsageStatsBuilder<'a, usage_stats_state::SetMonthlyPeriodStart<S>> {
self._fields.3 = Option::Some(value.into());
UsageStatsBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> UsageStatsBuilder<'a, S>
where
S: usage_stats_state::State,
S::MonthlyPostsCount: usage_stats_state::IsUnset,
{
pub fn monthly_posts_count(
mut self,
value: impl Into<i64>,
) -> UsageStatsBuilder<'a, usage_stats_state::SetMonthlyPostsCount<S>> {
self._fields.4 = Option::Some(value.into());
UsageStatsBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> UsageStatsBuilder<'a, S>
where
S: usage_stats_state::State,
S::PendingPostsCount: usage_stats_state::IsUnset,
{
pub fn pending_posts_count(
mut self,
value: impl Into<i64>,
) -> UsageStatsBuilder<'a, usage_stats_state::SetPendingPostsCount<S>> {
self._fields.5 = Option::Some(value.into());
UsageStatsBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: usage_stats_state::State> UsageStatsBuilder<'a, S> {
pub fn storage_used_mb(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_storage_used_mb(mut self, value: Option<i64>) -> Self {
self._fields.6 = value;
self
}
}
impl<'a, S> UsageStatsBuilder<'a, S>
where
S: usage_stats_state::State,
S::PendingPostsCount: usage_stats_state::IsSet,
S::LastUpdated: usage_stats_state::IsSet,
S::MonthlyPeriodEnd: usage_stats_state::IsSet,
S::MonthlyPostsCount: usage_stats_state::IsSet,
S::MonthlyPeriodStart: usage_stats_state::IsSet,
{
pub fn build(self) -> UsageStats<'a> {
UsageStats {
api_requests_this_hour: self._fields.0,
last_updated: self._fields.1.unwrap(),
monthly_period_end: self._fields.2.unwrap(),
monthly_period_start: self._fields.3.unwrap(),
monthly_posts_count: self._fields.4.unwrap(),
pending_posts_count: self._fields.5.unwrap(),
storage_used_mb: self._fields.6,
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
) -> UsageStats<'a> {
UsageStats {
api_requests_this_hour: self._fields.0,
last_updated: self._fields.1.unwrap(),
monthly_period_end: self._fields.2.unwrap(),
monthly_period_start: self._fields.3.unwrap(),
monthly_posts_count: self._fields.4.unwrap(),
pending_posts_count: self._fields.5.unwrap(),
storage_used_mb: self._fields.6,
extra_data: Some(extra_data),
}
}
}