#[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, Did};
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::tools_ozone::moderation::ModTool;
use crate::tools_ozone::moderation::schedule_action;
#[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 FailedScheduling<S: BosStr = DefaultStr> {
pub error: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub error_code: Option<S>,
pub subject: Did<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 ScheduleAction<S: BosStr = DefaultStr> {
pub action: schedule_action::Takedown<S>,
pub created_by: Did<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub mod_tool: Option<ModTool<S>>,
pub scheduling: schedule_action::SchedulingConfig<S>,
pub subjects: Vec<Did<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 ScheduleActionOutput<S: BosStr = DefaultStr> {
#[serde(flatten)]
pub value: Data<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 ScheduledActionResults<S: BosStr = DefaultStr> {
pub failed: Vec<schedule_action::FailedScheduling<S>>,
pub succeeded: Vec<Did<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 SchedulingConfig<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub execute_after: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
pub execute_at: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
pub execute_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, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Takedown<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub acknowledge_account_subjects: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub duration_in_hours: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub email_content: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub email_subject: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub policies: Option<Vec<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub severity_level: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub strike_count: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub strike_expires_at: Option<Datetime>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> LexiconSchema for FailedScheduling<S> {
fn nsid() -> &'static str {
"tools.ozone.moderation.scheduleAction"
}
fn def_name() -> &'static str {
"failedScheduling"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_tools_ozone_moderation_scheduleAction()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub struct ScheduleActionResponse;
impl jacquard_common::xrpc::XrpcResp for ScheduleActionResponse {
const NSID: &'static str = "tools.ozone.moderation.scheduleAction";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = ScheduleActionOutput<S>;
type Err = jacquard_common::xrpc::GenericError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for ScheduleAction<S> {
const NSID: &'static str = "tools.ozone.moderation.scheduleAction";
const METHOD: jacquard_common::xrpc::XrpcMethod =
jacquard_common::xrpc::XrpcMethod::Procedure("application/json");
type Response = ScheduleActionResponse;
}
pub struct ScheduleActionRequest;
impl jacquard_common::xrpc::XrpcEndpoint for ScheduleActionRequest {
const PATH: &'static str = "/xrpc/tools.ozone.moderation.scheduleAction";
const METHOD: jacquard_common::xrpc::XrpcMethod =
jacquard_common::xrpc::XrpcMethod::Procedure("application/json");
type Request<S: BosStr> = ScheduleAction<S>;
type Response = ScheduleActionResponse;
}
impl<S: BosStr> LexiconSchema for ScheduledActionResults<S> {
fn nsid() -> &'static str {
"tools.ozone.moderation.scheduleAction"
}
fn def_name() -> &'static str {
"scheduledActionResults"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_tools_ozone_moderation_scheduleAction()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for SchedulingConfig<S> {
fn nsid() -> &'static str {
"tools.ozone.moderation.scheduleAction"
}
fn def_name() -> &'static str {
"schedulingConfig"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_tools_ozone_moderation_scheduleAction()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Takedown<S> {
fn nsid() -> &'static str {
"tools.ozone.moderation.scheduleAction"
}
fn def_name() -> &'static str {
"takedown"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_tools_ozone_moderation_scheduleAction()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.policies {
#[allow(unused_comparisons)]
if value.len() > 5usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("policies"),
max: 5usize,
actual: value.len(),
});
}
}
Ok(())
}
}
pub mod failed_scheduling_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 Error;
type Subject;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Error = Unset;
type Subject = Unset;
}
pub struct SetError<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetError<St> {}
impl<St: State> State for SetError<St> {
type Error = Set<members::error>;
type Subject = St::Subject;
}
pub struct SetSubject<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSubject<St> {}
impl<St: State> State for SetSubject<St> {
type Error = St::Error;
type Subject = Set<members::subject>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct error(());
pub struct subject(());
}
}
pub struct FailedSchedulingBuilder<S: BosStr, St: failed_scheduling_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<S>, Option<S>, Option<Did<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> FailedScheduling<S> {
pub fn new() -> FailedSchedulingBuilder<S, failed_scheduling_state::Empty> {
FailedSchedulingBuilder::new()
}
}
impl<S: BosStr> FailedSchedulingBuilder<S, failed_scheduling_state::Empty> {
pub fn new() -> Self {
FailedSchedulingBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> FailedSchedulingBuilder<S, St>
where
St: failed_scheduling_state::State,
St::Error: failed_scheduling_state::IsUnset,
{
pub fn error(
mut self,
value: impl Into<S>,
) -> FailedSchedulingBuilder<S, failed_scheduling_state::SetError<St>> {
self._fields.0 = Option::Some(value.into());
FailedSchedulingBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: failed_scheduling_state::State> FailedSchedulingBuilder<S, St> {
pub fn error_code(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_error_code(mut self, value: Option<S>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> FailedSchedulingBuilder<S, St>
where
St: failed_scheduling_state::State,
St::Subject: failed_scheduling_state::IsUnset,
{
pub fn subject(
mut self,
value: impl Into<Did<S>>,
) -> FailedSchedulingBuilder<S, failed_scheduling_state::SetSubject<St>> {
self._fields.2 = Option::Some(value.into());
FailedSchedulingBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> FailedSchedulingBuilder<S, St>
where
St: failed_scheduling_state::State,
St::Error: failed_scheduling_state::IsSet,
St::Subject: failed_scheduling_state::IsSet,
{
pub fn build(self) -> FailedScheduling<S> {
FailedScheduling {
error: self._fields.0.unwrap(),
error_code: self._fields.1,
subject: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> FailedScheduling<S> {
FailedScheduling {
error: self._fields.0.unwrap(),
error_code: self._fields.1,
subject: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_tools_ozone_moderation_scheduleAction() -> 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("tools.ozone.moderation.scheduleAction"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("failedScheduling"),
LexUserType::Object(LexObject {
required: Some(vec![
SmolStr::new_static("subject"),
SmolStr::new_static("error"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("error"),
LexObjectProperty::String(LexString {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("errorCode"),
LexObjectProperty::String(LexString {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("subject"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::XrpcProcedure(LexXrpcProcedure {
input: Some(LexXrpcBody {
encoding: CowStr::new_static("application/json"),
schema: Some(LexXrpcBodySchema::Object(LexObject {
required: Some(vec![
SmolStr::new_static("action"),
SmolStr::new_static("subjects"),
SmolStr::new_static("createdBy"),
SmolStr::new_static("scheduling"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("action"),
LexObjectProperty::Union(LexRefUnion {
refs: vec![CowStr::new_static("#takedown")],
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createdBy"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("modTool"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static(
"tools.ozone.moderation.defs#modTool",
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("scheduling"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#schedulingConfig"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("subjects"),
LexObjectProperty::Array(LexArray {
description: Some(CowStr::new_static(
"Array of DID subjects to schedule the action for",
)),
items: LexArrayItem::String(LexString {
format: Some(LexStringFormat::Did),
..Default::default()
}),
max_length: Some(100usize),
..Default::default()
}),
);
map
},
..Default::default()
})),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("scheduledActionResults"),
LexUserType::Object(LexObject {
required: Some(vec![
SmolStr::new_static("succeeded"),
SmolStr::new_static("failed"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("failed"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#failedScheduling"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("succeeded"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::String(LexString {
format: Some(LexStringFormat::Did),
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("schedulingConfig"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Configuration for when the action should be executed",
),
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("executeAfter"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Earliest time to execute the action (for randomized scheduling)",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("executeAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Exact time to execute the action"),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("executeUntil"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Latest time to execute the action (for randomized scheduling)",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("takedown"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static("Schedule a takedown action")),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("acknowledgeAccountSubjects"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("comment"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map.insert(
SmolStr::new_static("durationInHours"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("emailContent"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Email content to be sent to the user upon takedown.",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("emailSubject"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Subject of the email to be sent to the user upon takedown.",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("policies"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"Names/Keywords of the policies that drove the decision.",
),
),
items: LexArrayItem::String(LexString {
..Default::default()
}),
max_length: Some(5usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("severityLevel"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Severity level of the violation (e.g., 'sev-0', 'sev-1', 'sev-2', etc.).",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("strikeCount"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("strikeExpiresAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"When the strike should expire. If not provided, the strike never expires.",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod schedule_action_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 Action;
type Subjects;
type Scheduling;
type CreatedBy;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Action = Unset;
type Subjects = Unset;
type Scheduling = Unset;
type CreatedBy = Unset;
}
pub struct SetAction<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetAction<St> {}
impl<St: State> State for SetAction<St> {
type Action = Set<members::action>;
type Subjects = St::Subjects;
type Scheduling = St::Scheduling;
type CreatedBy = St::CreatedBy;
}
pub struct SetSubjects<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSubjects<St> {}
impl<St: State> State for SetSubjects<St> {
type Action = St::Action;
type Subjects = Set<members::subjects>;
type Scheduling = St::Scheduling;
type CreatedBy = St::CreatedBy;
}
pub struct SetScheduling<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetScheduling<St> {}
impl<St: State> State for SetScheduling<St> {
type Action = St::Action;
type Subjects = St::Subjects;
type Scheduling = Set<members::scheduling>;
type CreatedBy = St::CreatedBy;
}
pub struct SetCreatedBy<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCreatedBy<St> {}
impl<St: State> State for SetCreatedBy<St> {
type Action = St::Action;
type Subjects = St::Subjects;
type Scheduling = St::Scheduling;
type CreatedBy = Set<members::created_by>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct action(());
pub struct subjects(());
pub struct scheduling(());
pub struct created_by(());
}
}
pub struct ScheduleActionBuilder<S: BosStr, St: schedule_action_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<schedule_action::Takedown<S>>,
Option<Did<S>>,
Option<ModTool<S>>,
Option<schedule_action::SchedulingConfig<S>>,
Option<Vec<Did<S>>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> ScheduleAction<S> {
pub fn new() -> ScheduleActionBuilder<S, schedule_action_state::Empty> {
ScheduleActionBuilder::new()
}
}
impl<S: BosStr> ScheduleActionBuilder<S, schedule_action_state::Empty> {
pub fn new() -> Self {
ScheduleActionBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ScheduleActionBuilder<S, St>
where
St: schedule_action_state::State,
St::Action: schedule_action_state::IsUnset,
{
pub fn action(
mut self,
value: impl Into<schedule_action::Takedown<S>>,
) -> ScheduleActionBuilder<S, schedule_action_state::SetAction<St>> {
self._fields.0 = Option::Some(value.into());
ScheduleActionBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ScheduleActionBuilder<S, St>
where
St: schedule_action_state::State,
St::CreatedBy: schedule_action_state::IsUnset,
{
pub fn created_by(
mut self,
value: impl Into<Did<S>>,
) -> ScheduleActionBuilder<S, schedule_action_state::SetCreatedBy<St>> {
self._fields.1 = Option::Some(value.into());
ScheduleActionBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: schedule_action_state::State> ScheduleActionBuilder<S, St> {
pub fn mod_tool(mut self, value: impl Into<Option<ModTool<S>>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_mod_tool(mut self, value: Option<ModTool<S>>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St> ScheduleActionBuilder<S, St>
where
St: schedule_action_state::State,
St::Scheduling: schedule_action_state::IsUnset,
{
pub fn scheduling(
mut self,
value: impl Into<schedule_action::SchedulingConfig<S>>,
) -> ScheduleActionBuilder<S, schedule_action_state::SetScheduling<St>> {
self._fields.3 = Option::Some(value.into());
ScheduleActionBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ScheduleActionBuilder<S, St>
where
St: schedule_action_state::State,
St::Subjects: schedule_action_state::IsUnset,
{
pub fn subjects(
mut self,
value: impl Into<Vec<Did<S>>>,
) -> ScheduleActionBuilder<S, schedule_action_state::SetSubjects<St>> {
self._fields.4 = Option::Some(value.into());
ScheduleActionBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ScheduleActionBuilder<S, St>
where
St: schedule_action_state::State,
St::Action: schedule_action_state::IsSet,
St::Subjects: schedule_action_state::IsSet,
St::Scheduling: schedule_action_state::IsSet,
St::CreatedBy: schedule_action_state::IsSet,
{
pub fn build(self) -> ScheduleAction<S> {
ScheduleAction {
action: self._fields.0.unwrap(),
created_by: self._fields.1.unwrap(),
mod_tool: self._fields.2,
scheduling: self._fields.3.unwrap(),
subjects: self._fields.4.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> ScheduleAction<S> {
ScheduleAction {
action: self._fields.0.unwrap(),
created_by: self._fields.1.unwrap(),
mod_tool: self._fields.2,
scheduling: self._fields.3.unwrap(),
subjects: self._fields.4.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod scheduled_action_results_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 Failed;
type Succeeded;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Failed = Unset;
type Succeeded = Unset;
}
pub struct SetFailed<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetFailed<St> {}
impl<St: State> State for SetFailed<St> {
type Failed = Set<members::failed>;
type Succeeded = St::Succeeded;
}
pub struct SetSucceeded<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSucceeded<St> {}
impl<St: State> State for SetSucceeded<St> {
type Failed = St::Failed;
type Succeeded = Set<members::succeeded>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct failed(());
pub struct succeeded(());
}
}
pub struct ScheduledActionResultsBuilder<S: BosStr, St: scheduled_action_results_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Vec<schedule_action::FailedScheduling<S>>>,
Option<Vec<Did<S>>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> ScheduledActionResults<S> {
pub fn new() -> ScheduledActionResultsBuilder<S, scheduled_action_results_state::Empty> {
ScheduledActionResultsBuilder::new()
}
}
impl<S: BosStr> ScheduledActionResultsBuilder<S, scheduled_action_results_state::Empty> {
pub fn new() -> Self {
ScheduledActionResultsBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ScheduledActionResultsBuilder<S, St>
where
St: scheduled_action_results_state::State,
St::Failed: scheduled_action_results_state::IsUnset,
{
pub fn failed(
mut self,
value: impl Into<Vec<schedule_action::FailedScheduling<S>>>,
) -> ScheduledActionResultsBuilder<S, scheduled_action_results_state::SetFailed<St>> {
self._fields.0 = Option::Some(value.into());
ScheduledActionResultsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ScheduledActionResultsBuilder<S, St>
where
St: scheduled_action_results_state::State,
St::Succeeded: scheduled_action_results_state::IsUnset,
{
pub fn succeeded(
mut self,
value: impl Into<Vec<Did<S>>>,
) -> ScheduledActionResultsBuilder<S, scheduled_action_results_state::SetSucceeded<St>> {
self._fields.1 = Option::Some(value.into());
ScheduledActionResultsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ScheduledActionResultsBuilder<S, St>
where
St: scheduled_action_results_state::State,
St::Failed: scheduled_action_results_state::IsSet,
St::Succeeded: scheduled_action_results_state::IsSet,
{
pub fn build(self) -> ScheduledActionResults<S> {
ScheduledActionResults {
failed: self._fields.0.unwrap(),
succeeded: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> ScheduledActionResults<S> {
ScheduledActionResults {
failed: self._fields.0.unwrap(),
succeeded: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}