#[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::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon, open_union};
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::diy_razorgirl::winter::job;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct IntervalSchedule<'a> {
pub seconds: i64,
#[serde(borrow)]
pub r#type: CowStr<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", rename = "diy.razorgirl.winter.job", tag = "$type")]
pub struct Job<'a> {
pub created_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default = "_default_job_failure_count")]
pub failure_count: Option<i64>,
#[serde(borrow)]
pub instructions: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
pub last_run: Option<Datetime>,
#[serde(borrow)]
pub name: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
pub next_run: Option<Datetime>,
#[serde(borrow)]
pub schedule: JobSchedule<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub status: Option<JobStatus<'a>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "'de: 'a"))]
pub enum JobSchedule<'a> {
#[serde(rename = "diy.razorgirl.winter.job#onceSchedule")]
OnceSchedule(Box<job::OnceSchedule<'a>>),
#[serde(rename = "diy.razorgirl.winter.job#intervalSchedule")]
IntervalSchedule(Box<job::IntervalSchedule<'a>>),
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum JobStatus<'a> {
Pending,
Running,
Completed,
Failed,
Other(CowStr<'a>),
}
impl<'a> JobStatus<'a> {
pub fn as_str(&self) -> &str {
match self {
Self::Pending => "pending",
Self::Running => "running",
Self::Completed => "completed",
Self::Failed => "failed",
Self::Other(s) => s.as_ref(),
}
}
}
impl<'a> From<&'a str> for JobStatus<'a> {
fn from(s: &'a str) -> Self {
match s {
"pending" => Self::Pending,
"running" => Self::Running,
"completed" => Self::Completed,
"failed" => Self::Failed,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> From<String> for JobStatus<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"pending" => Self::Pending,
"running" => Self::Running,
"completed" => Self::Completed,
"failed" => Self::Failed,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for JobStatus<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for JobStatus<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for JobStatus<'a> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, 'a> serde::Deserialize<'de> for JobStatus<'a>
where
'de: 'a,
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = <&'de str>::deserialize(deserializer)?;
Ok(Self::from(s))
}
}
impl<'a> Default for JobStatus<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for JobStatus<'_> {
type Output = JobStatus<'static>;
fn into_static(self) -> Self::Output {
match self {
JobStatus::Pending => JobStatus::Pending,
JobStatus::Running => JobStatus::Running,
JobStatus::Completed => JobStatus::Completed,
JobStatus::Failed => JobStatus::Failed,
JobStatus::Other(v) => JobStatus::Other(v.into_static()),
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct JobGetRecordOutput<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cid: Option<Cid<'a>>,
#[serde(borrow)]
pub uri: AtUri<'a>,
#[serde(borrow)]
pub value: Job<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct OnceSchedule<'a> {
pub run_at: Datetime,
#[serde(borrow)]
pub r#type: CowStr<'a>,
}
impl<'a> Job<'a> {
pub fn uri(
uri: impl Into<CowStr<'a>>,
) -> Result<RecordUri<'a, JobRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
}
}
impl<'a> LexiconSchema for IntervalSchedule<'a> {
fn nsid() -> &'static str {
"diy.razorgirl.winter.job"
}
fn def_name() -> &'static str {
"intervalSchedule"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_diy_razorgirl_winter_job()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct JobRecord;
impl XrpcResp for JobRecord {
const NSID: &'static str = "diy.razorgirl.winter.job";
const ENCODING: &'static str = "application/json";
type Output<'de> = JobGetRecordOutput<'de>;
type Err<'de> = RecordError<'de>;
}
impl From<JobGetRecordOutput<'_>> for Job<'_> {
fn from(output: JobGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl Collection for Job<'_> {
const NSID: &'static str = "diy.razorgirl.winter.job";
type Record = JobRecord;
}
impl Collection for JobRecord {
const NSID: &'static str = "diy.razorgirl.winter.job";
type Record = JobRecord;
}
impl<'a> LexiconSchema for Job<'a> {
fn nsid() -> &'static str {
"diy.razorgirl.winter.job"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_diy_razorgirl_winter_job()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.instructions;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 50000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("instructions"),
max: 50000usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.name;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 128usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("name"),
max: 128usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<'a> LexiconSchema for OnceSchedule<'a> {
fn nsid() -> &'static str {
"diy.razorgirl.winter.job"
}
fn def_name() -> &'static str {
"onceSchedule"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_diy_razorgirl_winter_job()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod interval_schedule_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 Type;
type Seconds;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Type = Unset;
type Seconds = Unset;
}
pub struct SetType<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetType<S> {}
impl<S: State> State for SetType<S> {
type Type = Set<members::r#type>;
type Seconds = S::Seconds;
}
pub struct SetSeconds<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetSeconds<S> {}
impl<S: State> State for SetSeconds<S> {
type Type = S::Type;
type Seconds = Set<members::seconds>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct r#type(());
pub struct seconds(());
}
}
pub struct IntervalScheduleBuilder<'a, S: interval_schedule_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<i64>, Option<CowStr<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> IntervalSchedule<'a> {
pub fn new() -> IntervalScheduleBuilder<'a, interval_schedule_state::Empty> {
IntervalScheduleBuilder::new()
}
}
impl<'a> IntervalScheduleBuilder<'a, interval_schedule_state::Empty> {
pub fn new() -> Self {
IntervalScheduleBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> IntervalScheduleBuilder<'a, S>
where
S: interval_schedule_state::State,
S::Seconds: interval_schedule_state::IsUnset,
{
pub fn seconds(
mut self,
value: impl Into<i64>,
) -> IntervalScheduleBuilder<'a, interval_schedule_state::SetSeconds<S>> {
self._fields.0 = Option::Some(value.into());
IntervalScheduleBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> IntervalScheduleBuilder<'a, S>
where
S: interval_schedule_state::State,
S::Type: interval_schedule_state::IsUnset,
{
pub fn r#type(
mut self,
value: impl Into<CowStr<'a>>,
) -> IntervalScheduleBuilder<'a, interval_schedule_state::SetType<S>> {
self._fields.1 = Option::Some(value.into());
IntervalScheduleBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> IntervalScheduleBuilder<'a, S>
where
S: interval_schedule_state::State,
S::Type: interval_schedule_state::IsSet,
S::Seconds: interval_schedule_state::IsSet,
{
pub fn build(self) -> IntervalSchedule<'a> {
IntervalSchedule {
seconds: self._fields.0.unwrap(),
r#type: 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>,
>,
) -> IntervalSchedule<'a> {
IntervalSchedule {
seconds: self._fields.0.unwrap(),
r#type: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_diy_razorgirl_winter_job() -> 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("diy.razorgirl.winter.job"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("intervalSchedule"),
LexUserType::Object(LexObject {
required: Some(
vec![SmolStr::new_static("type"), SmolStr::new_static("seconds")],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("seconds"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("type"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("name"),
SmolStr::new_static("instructions"),
SmolStr::new_static("schedule"),
SmolStr::new_static("createdAt")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("failureCount"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("instructions"),
LexObjectProperty::String(LexString {
max_length: Some(50000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("lastRun"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
max_length: Some(128usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("nextRun"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("schedule"),
LexObjectProperty::Union(LexRefUnion {
refs: vec![
CowStr::new_static("#onceSchedule"),
CowStr::new_static("#intervalSchedule")
],
..Default::default()
}),
);
map.insert(
SmolStr::new_static("status"),
LexObjectProperty::String(LexString {
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("onceSchedule"),
LexUserType::Object(LexObject {
required: Some(
vec![SmolStr::new_static("type"), SmolStr::new_static("runAt")],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("runAt"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("type"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
fn _default_job_failure_count() -> Option<i64> {
Some(0i64)
}
pub mod job_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 Instructions;
type CreatedAt;
type Schedule;
type Name;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Instructions = Unset;
type CreatedAt = Unset;
type Schedule = Unset;
type Name = Unset;
}
pub struct SetInstructions<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetInstructions<S> {}
impl<S: State> State for SetInstructions<S> {
type Instructions = Set<members::instructions>;
type CreatedAt = S::CreatedAt;
type Schedule = S::Schedule;
type Name = S::Name;
}
pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
impl<S: State> State for SetCreatedAt<S> {
type Instructions = S::Instructions;
type CreatedAt = Set<members::created_at>;
type Schedule = S::Schedule;
type Name = S::Name;
}
pub struct SetSchedule<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetSchedule<S> {}
impl<S: State> State for SetSchedule<S> {
type Instructions = S::Instructions;
type CreatedAt = S::CreatedAt;
type Schedule = Set<members::schedule>;
type Name = S::Name;
}
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 Instructions = S::Instructions;
type CreatedAt = S::CreatedAt;
type Schedule = S::Schedule;
type Name = Set<members::name>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct instructions(());
pub struct created_at(());
pub struct schedule(());
pub struct name(());
}
}
pub struct JobBuilder<'a, S: job_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<Datetime>,
Option<i64>,
Option<CowStr<'a>>,
Option<Datetime>,
Option<CowStr<'a>>,
Option<Datetime>,
Option<JobSchedule<'a>>,
Option<JobStatus<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Job<'a> {
pub fn new() -> JobBuilder<'a, job_state::Empty> {
JobBuilder::new()
}
}
impl<'a> JobBuilder<'a, job_state::Empty> {
pub fn new() -> Self {
JobBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> JobBuilder<'a, S>
where
S: job_state::State,
S::CreatedAt: job_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> JobBuilder<'a, job_state::SetCreatedAt<S>> {
self._fields.0 = Option::Some(value.into());
JobBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: job_state::State> JobBuilder<'a, S> {
pub fn failure_count(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_failure_count(mut self, value: Option<i64>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S> JobBuilder<'a, S>
where
S: job_state::State,
S::Instructions: job_state::IsUnset,
{
pub fn instructions(
mut self,
value: impl Into<CowStr<'a>>,
) -> JobBuilder<'a, job_state::SetInstructions<S>> {
self._fields.2 = Option::Some(value.into());
JobBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: job_state::State> JobBuilder<'a, S> {
pub fn last_run(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_last_run(mut self, value: Option<Datetime>) -> Self {
self._fields.3 = value;
self
}
}
impl<'a, S> JobBuilder<'a, S>
where
S: job_state::State,
S::Name: job_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<CowStr<'a>>,
) -> JobBuilder<'a, job_state::SetName<S>> {
self._fields.4 = Option::Some(value.into());
JobBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: job_state::State> JobBuilder<'a, S> {
pub fn next_run(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_next_run(mut self, value: Option<Datetime>) -> Self {
self._fields.5 = value;
self
}
}
impl<'a, S> JobBuilder<'a, S>
where
S: job_state::State,
S::Schedule: job_state::IsUnset,
{
pub fn schedule(
mut self,
value: impl Into<JobSchedule<'a>>,
) -> JobBuilder<'a, job_state::SetSchedule<S>> {
self._fields.6 = Option::Some(value.into());
JobBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: job_state::State> JobBuilder<'a, S> {
pub fn status(mut self, value: impl Into<Option<JobStatus<'a>>>) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_status(mut self, value: Option<JobStatus<'a>>) -> Self {
self._fields.7 = value;
self
}
}
impl<'a, S> JobBuilder<'a, S>
where
S: job_state::State,
S::Instructions: job_state::IsSet,
S::CreatedAt: job_state::IsSet,
S::Schedule: job_state::IsSet,
S::Name: job_state::IsSet,
{
pub fn build(self) -> Job<'a> {
Job {
created_at: self._fields.0.unwrap(),
failure_count: self._fields.1.or_else(|| Some(0i64)),
instructions: self._fields.2.unwrap(),
last_run: self._fields.3,
name: self._fields.4.unwrap(),
next_run: self._fields.5,
schedule: self._fields.6.unwrap(),
status: self._fields.7,
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>,
>,
) -> Job<'a> {
Job {
created_at: self._fields.0.unwrap(),
failure_count: self._fields.1.or_else(|| Some(0i64)),
instructions: self._fields.2.unwrap(),
last_run: self._fields.3,
name: self._fields.4.unwrap(),
next_run: self._fields.5,
schedule: self._fields.6.unwrap(),
status: self._fields.7,
extra_data: Some(extra_data),
}
}
}
pub mod once_schedule_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 RunAt;
type Type;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type RunAt = Unset;
type Type = Unset;
}
pub struct SetRunAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetRunAt<S> {}
impl<S: State> State for SetRunAt<S> {
type RunAt = Set<members::run_at>;
type Type = S::Type;
}
pub struct SetType<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetType<S> {}
impl<S: State> State for SetType<S> {
type RunAt = S::RunAt;
type Type = Set<members::r#type>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct run_at(());
pub struct r#type(());
}
}
pub struct OnceScheduleBuilder<'a, S: once_schedule_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<Datetime>, Option<CowStr<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> OnceSchedule<'a> {
pub fn new() -> OnceScheduleBuilder<'a, once_schedule_state::Empty> {
OnceScheduleBuilder::new()
}
}
impl<'a> OnceScheduleBuilder<'a, once_schedule_state::Empty> {
pub fn new() -> Self {
OnceScheduleBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> OnceScheduleBuilder<'a, S>
where
S: once_schedule_state::State,
S::RunAt: once_schedule_state::IsUnset,
{
pub fn run_at(
mut self,
value: impl Into<Datetime>,
) -> OnceScheduleBuilder<'a, once_schedule_state::SetRunAt<S>> {
self._fields.0 = Option::Some(value.into());
OnceScheduleBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> OnceScheduleBuilder<'a, S>
where
S: once_schedule_state::State,
S::Type: once_schedule_state::IsUnset,
{
pub fn r#type(
mut self,
value: impl Into<CowStr<'a>>,
) -> OnceScheduleBuilder<'a, once_schedule_state::SetType<S>> {
self._fields.1 = Option::Some(value.into());
OnceScheduleBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> OnceScheduleBuilder<'a, S>
where
S: once_schedule_state::State,
S::RunAt: once_schedule_state::IsSet,
S::Type: once_schedule_state::IsSet,
{
pub fn build(self) -> OnceSchedule<'a> {
OnceSchedule {
run_at: self._fields.0.unwrap(),
r#type: 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>,
>,
) -> OnceSchedule<'a> {
OnceSchedule {
run_at: self._fields.0.unwrap(),
r#type: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}