#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::Datetime;
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::app_chronosky::plan::get_usage;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct CurrentPlan<S: BosStr = DefaultStr> {
pub display_name: Data<S>,
pub id: S,
pub is_active: bool,
pub name: S,
pub tier: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub valid_until: Option<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 GetUsageOutput<S: BosStr = DefaultStr> {
pub current_plan: get_usage::CurrentPlan<S>,
pub limits: get_usage::PlanLimits<S>,
pub usage: get_usage::UsageStats<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)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct PlanLimits<S: BosStr = DefaultStr> {
#[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>,
#[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 UsageStats<S: BosStr = DefaultStr> {
#[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>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> LexiconSchema for CurrentPlan<S> {
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<S: BosStr> = GetUsageOutput<S>;
type Err = jacquard_common::xrpc::GenericError;
}
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<S: BosStr> = GetUsage;
type Response = GetUsageResponse;
}
impl<S: BosStr> LexiconSchema for PlanLimits<S> {
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<S: BosStr> LexiconSchema for UsageStats<S> {
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::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Name;
type IsActive;
type Tier;
type DisplayName;
type Id;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Name = Unset;
type IsActive = Unset;
type Tier = Unset;
type DisplayName = Unset;
type Id = Unset;
}
pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetName<St> {}
impl<St: State> State for SetName<St> {
type Name = Set<members::name>;
type IsActive = St::IsActive;
type Tier = St::Tier;
type DisplayName = St::DisplayName;
type Id = St::Id;
}
pub struct SetIsActive<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetIsActive<St> {}
impl<St: State> State for SetIsActive<St> {
type Name = St::Name;
type IsActive = Set<members::is_active>;
type Tier = St::Tier;
type DisplayName = St::DisplayName;
type Id = St::Id;
}
pub struct SetTier<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetTier<St> {}
impl<St: State> State for SetTier<St> {
type Name = St::Name;
type IsActive = St::IsActive;
type Tier = Set<members::tier>;
type DisplayName = St::DisplayName;
type Id = St::Id;
}
pub struct SetDisplayName<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDisplayName<St> {}
impl<St: State> State for SetDisplayName<St> {
type Name = St::Name;
type IsActive = St::IsActive;
type Tier = St::Tier;
type DisplayName = Set<members::display_name>;
type Id = St::Id;
}
pub struct SetId<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetId<St> {}
impl<St: State> State for SetId<St> {
type Name = St::Name;
type IsActive = St::IsActive;
type Tier = St::Tier;
type DisplayName = St::DisplayName;
type Id = Set<members::id>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct name(());
pub struct is_active(());
pub struct tier(());
pub struct display_name(());
pub struct id(());
}
}
pub struct CurrentPlanBuilder<S: BosStr, St: current_plan_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Data<S>>,
Option<S>,
Option<bool>,
Option<S>,
Option<S>,
Option<Datetime>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> CurrentPlan<S> {
pub fn new() -> CurrentPlanBuilder<S, current_plan_state::Empty> {
CurrentPlanBuilder::new()
}
}
impl<S: BosStr> CurrentPlanBuilder<S, current_plan_state::Empty> {
pub fn new() -> Self {
CurrentPlanBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CurrentPlanBuilder<S, St>
where
St: current_plan_state::State,
St::DisplayName: current_plan_state::IsUnset,
{
pub fn display_name(
mut self,
value: impl Into<Data<S>>,
) -> CurrentPlanBuilder<S, current_plan_state::SetDisplayName<St>> {
self._fields.0 = Option::Some(value.into());
CurrentPlanBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CurrentPlanBuilder<S, St>
where
St: current_plan_state::State,
St::Id: current_plan_state::IsUnset,
{
pub fn id(
mut self,
value: impl Into<S>,
) -> CurrentPlanBuilder<S, current_plan_state::SetId<St>> {
self._fields.1 = Option::Some(value.into());
CurrentPlanBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CurrentPlanBuilder<S, St>
where
St: current_plan_state::State,
St::IsActive: current_plan_state::IsUnset,
{
pub fn is_active(
mut self,
value: impl Into<bool>,
) -> CurrentPlanBuilder<S, current_plan_state::SetIsActive<St>> {
self._fields.2 = Option::Some(value.into());
CurrentPlanBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CurrentPlanBuilder<S, St>
where
St: current_plan_state::State,
St::Name: current_plan_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<S>,
) -> CurrentPlanBuilder<S, current_plan_state::SetName<St>> {
self._fields.3 = Option::Some(value.into());
CurrentPlanBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CurrentPlanBuilder<S, St>
where
St: current_plan_state::State,
St::Tier: current_plan_state::IsUnset,
{
pub fn tier(
mut self,
value: impl Into<S>,
) -> CurrentPlanBuilder<S, current_plan_state::SetTier<St>> {
self._fields.4 = Option::Some(value.into());
CurrentPlanBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: current_plan_state::State> CurrentPlanBuilder<S, St> {
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<S: BosStr, St> CurrentPlanBuilder<S, St>
where
St: current_plan_state::State,
St::Name: current_plan_state::IsSet,
St::IsActive: current_plan_state::IsSet,
St::Tier: current_plan_state::IsSet,
St::DisplayName: current_plan_state::IsSet,
St::Id: current_plan_state::IsSet,
{
pub fn build(self) -> CurrentPlan<S> {
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<SmolStr, Data<S>>) -> CurrentPlan<S> {
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> {
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
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::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type ScheduleIntervalMinutes;
type MaxImagesPerPost;
type MonthlyPostsLimit;
type MaxScheduleDays;
type PendingPostsLimit;
type ThreadPostsLimit;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type ScheduleIntervalMinutes = Unset;
type MaxImagesPerPost = Unset;
type MonthlyPostsLimit = Unset;
type MaxScheduleDays = Unset;
type PendingPostsLimit = Unset;
type ThreadPostsLimit = Unset;
}
pub struct SetScheduleIntervalMinutes<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetScheduleIntervalMinutes<St> {}
impl<St: State> State for SetScheduleIntervalMinutes<St> {
type ScheduleIntervalMinutes = Set<members::schedule_interval_minutes>;
type MaxImagesPerPost = St::MaxImagesPerPost;
type MonthlyPostsLimit = St::MonthlyPostsLimit;
type MaxScheduleDays = St::MaxScheduleDays;
type PendingPostsLimit = St::PendingPostsLimit;
type ThreadPostsLimit = St::ThreadPostsLimit;
}
pub struct SetMaxImagesPerPost<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMaxImagesPerPost<St> {}
impl<St: State> State for SetMaxImagesPerPost<St> {
type ScheduleIntervalMinutes = St::ScheduleIntervalMinutes;
type MaxImagesPerPost = Set<members::max_images_per_post>;
type MonthlyPostsLimit = St::MonthlyPostsLimit;
type MaxScheduleDays = St::MaxScheduleDays;
type PendingPostsLimit = St::PendingPostsLimit;
type ThreadPostsLimit = St::ThreadPostsLimit;
}
pub struct SetMonthlyPostsLimit<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMonthlyPostsLimit<St> {}
impl<St: State> State for SetMonthlyPostsLimit<St> {
type ScheduleIntervalMinutes = St::ScheduleIntervalMinutes;
type MaxImagesPerPost = St::MaxImagesPerPost;
type MonthlyPostsLimit = Set<members::monthly_posts_limit>;
type MaxScheduleDays = St::MaxScheduleDays;
type PendingPostsLimit = St::PendingPostsLimit;
type ThreadPostsLimit = St::ThreadPostsLimit;
}
pub struct SetMaxScheduleDays<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMaxScheduleDays<St> {}
impl<St: State> State for SetMaxScheduleDays<St> {
type ScheduleIntervalMinutes = St::ScheduleIntervalMinutes;
type MaxImagesPerPost = St::MaxImagesPerPost;
type MonthlyPostsLimit = St::MonthlyPostsLimit;
type MaxScheduleDays = Set<members::max_schedule_days>;
type PendingPostsLimit = St::PendingPostsLimit;
type ThreadPostsLimit = St::ThreadPostsLimit;
}
pub struct SetPendingPostsLimit<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetPendingPostsLimit<St> {}
impl<St: State> State for SetPendingPostsLimit<St> {
type ScheduleIntervalMinutes = St::ScheduleIntervalMinutes;
type MaxImagesPerPost = St::MaxImagesPerPost;
type MonthlyPostsLimit = St::MonthlyPostsLimit;
type MaxScheduleDays = St::MaxScheduleDays;
type PendingPostsLimit = Set<members::pending_posts_limit>;
type ThreadPostsLimit = St::ThreadPostsLimit;
}
pub struct SetThreadPostsLimit<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetThreadPostsLimit<St> {}
impl<St: State> State for SetThreadPostsLimit<St> {
type ScheduleIntervalMinutes = St::ScheduleIntervalMinutes;
type MaxImagesPerPost = St::MaxImagesPerPost;
type MonthlyPostsLimit = St::MonthlyPostsLimit;
type MaxScheduleDays = St::MaxScheduleDays;
type PendingPostsLimit = St::PendingPostsLimit;
type ThreadPostsLimit = Set<members::thread_posts_limit>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct schedule_interval_minutes(());
pub struct max_images_per_post(());
pub struct monthly_posts_limit(());
pub struct max_schedule_days(());
pub struct pending_posts_limit(());
pub struct thread_posts_limit(());
}
}
pub struct PlanLimitsBuilder<S: BosStr, St: plan_limits_state::State> {
_state: PhantomData<fn() -> St>,
_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>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> PlanLimits<S> {
pub fn new() -> PlanLimitsBuilder<S, plan_limits_state::Empty> {
PlanLimitsBuilder::new()
}
}
impl<S: BosStr> PlanLimitsBuilder<S, plan_limits_state::Empty> {
pub fn new() -> Self {
PlanLimitsBuilder {
_state: PhantomData,
_fields: (
None, None, None, None, None, None, None, None, None, None, None, None,
),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: plan_limits_state::State> PlanLimitsBuilder<S, St> {
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<S: BosStr, St: plan_limits_state::State> PlanLimitsBuilder<S, St> {
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<S: BosStr, St> PlanLimitsBuilder<S, St>
where
St: plan_limits_state::State,
St::MaxImagesPerPost: plan_limits_state::IsUnset,
{
pub fn max_images_per_post(
mut self,
value: impl Into<i64>,
) -> PlanLimitsBuilder<S, plan_limits_state::SetMaxImagesPerPost<St>> {
self._fields.2 = Option::Some(value.into());
PlanLimitsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PlanLimitsBuilder<S, St>
where
St: plan_limits_state::State,
St::MaxScheduleDays: plan_limits_state::IsUnset,
{
pub fn max_schedule_days(
mut self,
value: impl Into<i64>,
) -> PlanLimitsBuilder<S, plan_limits_state::SetMaxScheduleDays<St>> {
self._fields.3 = Option::Some(value.into());
PlanLimitsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: plan_limits_state::State> PlanLimitsBuilder<S, St> {
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<S: BosStr, St> PlanLimitsBuilder<S, St>
where
St: plan_limits_state::State,
St::MonthlyPostsLimit: plan_limits_state::IsUnset,
{
pub fn monthly_posts_limit(
mut self,
value: impl Into<i64>,
) -> PlanLimitsBuilder<S, plan_limits_state::SetMonthlyPostsLimit<St>> {
self._fields.5 = Option::Some(value.into());
PlanLimitsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PlanLimitsBuilder<S, St>
where
St: plan_limits_state::State,
St::PendingPostsLimit: plan_limits_state::IsUnset,
{
pub fn pending_posts_limit(
mut self,
value: impl Into<i64>,
) -> PlanLimitsBuilder<S, plan_limits_state::SetPendingPostsLimit<St>> {
self._fields.6 = Option::Some(value.into());
PlanLimitsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PlanLimitsBuilder<S, St>
where
St: plan_limits_state::State,
St::ScheduleIntervalMinutes: plan_limits_state::IsUnset,
{
pub fn schedule_interval_minutes(
mut self,
value: impl Into<i64>,
) -> PlanLimitsBuilder<S, plan_limits_state::SetScheduleIntervalMinutes<St>> {
self._fields.7 = Option::Some(value.into());
PlanLimitsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: plan_limits_state::State> PlanLimitsBuilder<S, St> {
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<S: BosStr, St> PlanLimitsBuilder<S, St>
where
St: plan_limits_state::State,
St::ThreadPostsLimit: plan_limits_state::IsUnset,
{
pub fn thread_posts_limit(
mut self,
value: impl Into<i64>,
) -> PlanLimitsBuilder<S, plan_limits_state::SetThreadPostsLimit<St>> {
self._fields.9 = Option::Some(value.into());
PlanLimitsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: plan_limits_state::State> PlanLimitsBuilder<S, St> {
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<S: BosStr, St: plan_limits_state::State> PlanLimitsBuilder<S, St> {
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<S: BosStr, St> PlanLimitsBuilder<S, St>
where
St: plan_limits_state::State,
St::ScheduleIntervalMinutes: plan_limits_state::IsSet,
St::MaxImagesPerPost: plan_limits_state::IsSet,
St::MonthlyPostsLimit: plan_limits_state::IsSet,
St::MaxScheduleDays: plan_limits_state::IsSet,
St::PendingPostsLimit: plan_limits_state::IsSet,
St::ThreadPostsLimit: plan_limits_state::IsSet,
{
pub fn build(self) -> PlanLimits<S> {
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<SmolStr, Data<S>>) -> PlanLimits<S> {
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::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type MonthlyPeriodEnd;
type MonthlyPostsCount;
type MonthlyPeriodStart;
type PendingPostsCount;
type LastUpdated;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type MonthlyPeriodEnd = Unset;
type MonthlyPostsCount = Unset;
type MonthlyPeriodStart = Unset;
type PendingPostsCount = Unset;
type LastUpdated = Unset;
}
pub struct SetMonthlyPeriodEnd<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMonthlyPeriodEnd<St> {}
impl<St: State> State for SetMonthlyPeriodEnd<St> {
type MonthlyPeriodEnd = Set<members::monthly_period_end>;
type MonthlyPostsCount = St::MonthlyPostsCount;
type MonthlyPeriodStart = St::MonthlyPeriodStart;
type PendingPostsCount = St::PendingPostsCount;
type LastUpdated = St::LastUpdated;
}
pub struct SetMonthlyPostsCount<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMonthlyPostsCount<St> {}
impl<St: State> State for SetMonthlyPostsCount<St> {
type MonthlyPeriodEnd = St::MonthlyPeriodEnd;
type MonthlyPostsCount = Set<members::monthly_posts_count>;
type MonthlyPeriodStart = St::MonthlyPeriodStart;
type PendingPostsCount = St::PendingPostsCount;
type LastUpdated = St::LastUpdated;
}
pub struct SetMonthlyPeriodStart<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMonthlyPeriodStart<St> {}
impl<St: State> State for SetMonthlyPeriodStart<St> {
type MonthlyPeriodEnd = St::MonthlyPeriodEnd;
type MonthlyPostsCount = St::MonthlyPostsCount;
type MonthlyPeriodStart = Set<members::monthly_period_start>;
type PendingPostsCount = St::PendingPostsCount;
type LastUpdated = St::LastUpdated;
}
pub struct SetPendingPostsCount<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetPendingPostsCount<St> {}
impl<St: State> State for SetPendingPostsCount<St> {
type MonthlyPeriodEnd = St::MonthlyPeriodEnd;
type MonthlyPostsCount = St::MonthlyPostsCount;
type MonthlyPeriodStart = St::MonthlyPeriodStart;
type PendingPostsCount = Set<members::pending_posts_count>;
type LastUpdated = St::LastUpdated;
}
pub struct SetLastUpdated<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetLastUpdated<St> {}
impl<St: State> State for SetLastUpdated<St> {
type MonthlyPeriodEnd = St::MonthlyPeriodEnd;
type MonthlyPostsCount = St::MonthlyPostsCount;
type MonthlyPeriodStart = St::MonthlyPeriodStart;
type PendingPostsCount = St::PendingPostsCount;
type LastUpdated = Set<members::last_updated>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct monthly_period_end(());
pub struct monthly_posts_count(());
pub struct monthly_period_start(());
pub struct pending_posts_count(());
pub struct last_updated(());
}
}
pub struct UsageStatsBuilder<S: BosStr, St: usage_stats_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<i64>,
Option<Datetime>,
Option<Datetime>,
Option<Datetime>,
Option<i64>,
Option<i64>,
Option<i64>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> UsageStats<S> {
pub fn new() -> UsageStatsBuilder<S, usage_stats_state::Empty> {
UsageStatsBuilder::new()
}
}
impl<S: BosStr> UsageStatsBuilder<S, usage_stats_state::Empty> {
pub fn new() -> Self {
UsageStatsBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: usage_stats_state::State> UsageStatsBuilder<S, St> {
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<S: BosStr, St> UsageStatsBuilder<S, St>
where
St: usage_stats_state::State,
St::LastUpdated: usage_stats_state::IsUnset,
{
pub fn last_updated(
mut self,
value: impl Into<Datetime>,
) -> UsageStatsBuilder<S, usage_stats_state::SetLastUpdated<St>> {
self._fields.1 = Option::Some(value.into());
UsageStatsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> UsageStatsBuilder<S, St>
where
St: usage_stats_state::State,
St::MonthlyPeriodEnd: usage_stats_state::IsUnset,
{
pub fn monthly_period_end(
mut self,
value: impl Into<Datetime>,
) -> UsageStatsBuilder<S, usage_stats_state::SetMonthlyPeriodEnd<St>> {
self._fields.2 = Option::Some(value.into());
UsageStatsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> UsageStatsBuilder<S, St>
where
St: usage_stats_state::State,
St::MonthlyPeriodStart: usage_stats_state::IsUnset,
{
pub fn monthly_period_start(
mut self,
value: impl Into<Datetime>,
) -> UsageStatsBuilder<S, usage_stats_state::SetMonthlyPeriodStart<St>> {
self._fields.3 = Option::Some(value.into());
UsageStatsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> UsageStatsBuilder<S, St>
where
St: usage_stats_state::State,
St::MonthlyPostsCount: usage_stats_state::IsUnset,
{
pub fn monthly_posts_count(
mut self,
value: impl Into<i64>,
) -> UsageStatsBuilder<S, usage_stats_state::SetMonthlyPostsCount<St>> {
self._fields.4 = Option::Some(value.into());
UsageStatsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> UsageStatsBuilder<S, St>
where
St: usage_stats_state::State,
St::PendingPostsCount: usage_stats_state::IsUnset,
{
pub fn pending_posts_count(
mut self,
value: impl Into<i64>,
) -> UsageStatsBuilder<S, usage_stats_state::SetPendingPostsCount<St>> {
self._fields.5 = Option::Some(value.into());
UsageStatsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: usage_stats_state::State> UsageStatsBuilder<S, St> {
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<S: BosStr, St> UsageStatsBuilder<S, St>
where
St: usage_stats_state::State,
St::MonthlyPeriodEnd: usage_stats_state::IsSet,
St::MonthlyPostsCount: usage_stats_state::IsSet,
St::MonthlyPeriodStart: usage_stats_state::IsSet,
St::PendingPostsCount: usage_stats_state::IsSet,
St::LastUpdated: usage_stats_state::IsSet,
{
pub fn build(self) -> UsageStats<S> {
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<SmolStr, Data<S>>) -> UsageStats<S> {
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),
}
}
}