#[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::{Did, Datetime};
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::tools_ozone::moderation::ModTool;
use crate::tools_ozone::moderation::schedule_action;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct FailedScheduling<'a> {
#[serde(borrow)]
pub error: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub error_code: Option<CowStr<'a>>,
#[serde(borrow)]
pub subject: Did<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ScheduleAction<'a> {
#[serde(borrow)]
pub action: schedule_action::Takedown<'a>,
#[serde(borrow)]
pub created_by: Did<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub mod_tool: Option<ModTool<'a>>,
#[serde(borrow)]
pub scheduling: schedule_action::SchedulingConfig<'a>,
#[serde(borrow)]
pub subjects: Vec<Did<'a>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ScheduleActionOutput<'a> {
#[serde(flatten)]
#[serde(borrow)]
pub value: jacquard_common::types::value::Data<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ScheduledActionResults<'a> {
#[serde(borrow)]
pub failed: Vec<schedule_action::FailedScheduling<'a>>,
#[serde(borrow)]
pub succeeded: Vec<Did<'a>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct SchedulingConfig<'a> {
#[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>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Takedown<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
pub acknowledge_account_subjects: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub comment: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub duration_in_hours: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub email_content: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub email_subject: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub policies: Option<Vec<CowStr<'a>>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub severity_level: Option<CowStr<'a>>,
#[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>,
}
impl<'a> LexiconSchema for FailedScheduling<'a> {
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<'de> = ScheduleActionOutput<'de>;
type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}
impl<'a> jacquard_common::xrpc::XrpcRequest for ScheduleAction<'a> {
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<'de> = ScheduleAction<'de>;
type Response = ScheduleActionResponse;
}
impl<'a> LexiconSchema for ScheduledActionResults<'a> {
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<'a> LexiconSchema for SchedulingConfig<'a> {
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<'a> LexiconSchema for Takedown<'a> {
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::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Subject;
type Error;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Subject = Unset;
type Error = Unset;
}
pub struct SetSubject<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetSubject<S> {}
impl<S: State> State for SetSubject<S> {
type Subject = Set<members::subject>;
type Error = S::Error;
}
pub struct SetError<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetError<S> {}
impl<S: State> State for SetError<S> {
type Subject = S::Subject;
type Error = Set<members::error>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct subject(());
pub struct error(());
}
}
pub struct FailedSchedulingBuilder<'a, S: failed_scheduling_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<CowStr<'a>>, Option<CowStr<'a>>, Option<Did<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> FailedScheduling<'a> {
pub fn new() -> FailedSchedulingBuilder<'a, failed_scheduling_state::Empty> {
FailedSchedulingBuilder::new()
}
}
impl<'a> FailedSchedulingBuilder<'a, failed_scheduling_state::Empty> {
pub fn new() -> Self {
FailedSchedulingBuilder {
_state: PhantomData,
_fields: (None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> FailedSchedulingBuilder<'a, S>
where
S: failed_scheduling_state::State,
S::Error: failed_scheduling_state::IsUnset,
{
pub fn error(
mut self,
value: impl Into<CowStr<'a>>,
) -> FailedSchedulingBuilder<'a, failed_scheduling_state::SetError<S>> {
self._fields.0 = Option::Some(value.into());
FailedSchedulingBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: failed_scheduling_state::State> FailedSchedulingBuilder<'a, S> {
pub fn error_code(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_error_code(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S> FailedSchedulingBuilder<'a, S>
where
S: failed_scheduling_state::State,
S::Subject: failed_scheduling_state::IsUnset,
{
pub fn subject(
mut self,
value: impl Into<Did<'a>>,
) -> FailedSchedulingBuilder<'a, failed_scheduling_state::SetSubject<S>> {
self._fields.2 = Option::Some(value.into());
FailedSchedulingBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> FailedSchedulingBuilder<'a, S>
where
S: failed_scheduling_state::State,
S::Subject: failed_scheduling_state::IsSet,
S::Error: failed_scheduling_state::IsSet,
{
pub fn build(self) -> FailedScheduling<'a> {
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<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> FailedScheduling<'a> {
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> {
#[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("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::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Subjects;
type Scheduling;
type Action;
type CreatedBy;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Subjects = Unset;
type Scheduling = Unset;
type Action = Unset;
type CreatedBy = Unset;
}
pub struct SetSubjects<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetSubjects<S> {}
impl<S: State> State for SetSubjects<S> {
type Subjects = Set<members::subjects>;
type Scheduling = S::Scheduling;
type Action = S::Action;
type CreatedBy = S::CreatedBy;
}
pub struct SetScheduling<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetScheduling<S> {}
impl<S: State> State for SetScheduling<S> {
type Subjects = S::Subjects;
type Scheduling = Set<members::scheduling>;
type Action = S::Action;
type CreatedBy = S::CreatedBy;
}
pub struct SetAction<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetAction<S> {}
impl<S: State> State for SetAction<S> {
type Subjects = S::Subjects;
type Scheduling = S::Scheduling;
type Action = Set<members::action>;
type CreatedBy = S::CreatedBy;
}
pub struct SetCreatedBy<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCreatedBy<S> {}
impl<S: State> State for SetCreatedBy<S> {
type Subjects = S::Subjects;
type Scheduling = S::Scheduling;
type Action = S::Action;
type CreatedBy = Set<members::created_by>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct subjects(());
pub struct scheduling(());
pub struct action(());
pub struct created_by(());
}
}
pub struct ScheduleActionBuilder<'a, S: schedule_action_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<schedule_action::Takedown<'a>>,
Option<Did<'a>>,
Option<ModTool<'a>>,
Option<schedule_action::SchedulingConfig<'a>>,
Option<Vec<Did<'a>>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> ScheduleAction<'a> {
pub fn new() -> ScheduleActionBuilder<'a, schedule_action_state::Empty> {
ScheduleActionBuilder::new()
}
}
impl<'a> ScheduleActionBuilder<'a, schedule_action_state::Empty> {
pub fn new() -> Self {
ScheduleActionBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> ScheduleActionBuilder<'a, S>
where
S: schedule_action_state::State,
S::Action: schedule_action_state::IsUnset,
{
pub fn action(
mut self,
value: impl Into<schedule_action::Takedown<'a>>,
) -> ScheduleActionBuilder<'a, schedule_action_state::SetAction<S>> {
self._fields.0 = Option::Some(value.into());
ScheduleActionBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ScheduleActionBuilder<'a, S>
where
S: schedule_action_state::State,
S::CreatedBy: schedule_action_state::IsUnset,
{
pub fn created_by(
mut self,
value: impl Into<Did<'a>>,
) -> ScheduleActionBuilder<'a, schedule_action_state::SetCreatedBy<S>> {
self._fields.1 = Option::Some(value.into());
ScheduleActionBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: schedule_action_state::State> ScheduleActionBuilder<'a, S> {
pub fn mod_tool(mut self, value: impl Into<Option<ModTool<'a>>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_mod_tool(mut self, value: Option<ModTool<'a>>) -> Self {
self._fields.2 = value;
self
}
}
impl<'a, S> ScheduleActionBuilder<'a, S>
where
S: schedule_action_state::State,
S::Scheduling: schedule_action_state::IsUnset,
{
pub fn scheduling(
mut self,
value: impl Into<schedule_action::SchedulingConfig<'a>>,
) -> ScheduleActionBuilder<'a, schedule_action_state::SetScheduling<S>> {
self._fields.3 = Option::Some(value.into());
ScheduleActionBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ScheduleActionBuilder<'a, S>
where
S: schedule_action_state::State,
S::Subjects: schedule_action_state::IsUnset,
{
pub fn subjects(
mut self,
value: impl Into<Vec<Did<'a>>>,
) -> ScheduleActionBuilder<'a, schedule_action_state::SetSubjects<S>> {
self._fields.4 = Option::Some(value.into());
ScheduleActionBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ScheduleActionBuilder<'a, S>
where
S: schedule_action_state::State,
S::Subjects: schedule_action_state::IsSet,
S::Scheduling: schedule_action_state::IsSet,
S::Action: schedule_action_state::IsSet,
S::CreatedBy: schedule_action_state::IsSet,
{
pub fn build(self) -> ScheduleAction<'a> {
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<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> ScheduleAction<'a> {
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::{Set, Unset, IsSet, IsUnset};
#[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<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetFailed<S> {}
impl<S: State> State for SetFailed<S> {
type Failed = Set<members::failed>;
type Succeeded = S::Succeeded;
}
pub struct SetSucceeded<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetSucceeded<S> {}
impl<S: State> State for SetSucceeded<S> {
type Failed = S::Failed;
type Succeeded = Set<members::succeeded>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct failed(());
pub struct succeeded(());
}
}
pub struct ScheduledActionResultsBuilder<'a, S: scheduled_action_results_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<Vec<schedule_action::FailedScheduling<'a>>>, Option<Vec<Did<'a>>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> ScheduledActionResults<'a> {
pub fn new() -> ScheduledActionResultsBuilder<
'a,
scheduled_action_results_state::Empty,
> {
ScheduledActionResultsBuilder::new()
}
}
impl<'a> ScheduledActionResultsBuilder<'a, scheduled_action_results_state::Empty> {
pub fn new() -> Self {
ScheduledActionResultsBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> ScheduledActionResultsBuilder<'a, S>
where
S: scheduled_action_results_state::State,
S::Failed: scheduled_action_results_state::IsUnset,
{
pub fn failed(
mut self,
value: impl Into<Vec<schedule_action::FailedScheduling<'a>>>,
) -> ScheduledActionResultsBuilder<
'a,
scheduled_action_results_state::SetFailed<S>,
> {
self._fields.0 = Option::Some(value.into());
ScheduledActionResultsBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ScheduledActionResultsBuilder<'a, S>
where
S: scheduled_action_results_state::State,
S::Succeeded: scheduled_action_results_state::IsUnset,
{
pub fn succeeded(
mut self,
value: impl Into<Vec<Did<'a>>>,
) -> ScheduledActionResultsBuilder<
'a,
scheduled_action_results_state::SetSucceeded<S>,
> {
self._fields.1 = Option::Some(value.into());
ScheduledActionResultsBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ScheduledActionResultsBuilder<'a, S>
where
S: scheduled_action_results_state::State,
S::Failed: scheduled_action_results_state::IsSet,
S::Succeeded: scheduled_action_results_state::IsSet,
{
pub fn build(self) -> ScheduledActionResults<'a> {
ScheduledActionResults {
failed: self._fields.0.unwrap(),
succeeded: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> ScheduledActionResults<'a> {
ScheduledActionResults {
failed: self._fields.0.unwrap(),
succeeded: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}