Struct Job
pub struct Job {
info: JobInfo,
mqtt: MqttClient,
accepted: Option<OwnedSubscriber>,
rejected: Option<OwnedSubscriber>,
}Expand description
The Job struct represents a job execution and provides methods for
updating it’s status.
Fields§
§info: JobInfo§mqtt: MqttClient§accepted: Option<OwnedSubscriber>§rejected: Option<OwnedSubscriber>Implementations§
§impl Job
impl Job
const fn new(info: JobInfo, mqtt: MqttClient) -> Self
const fn new(info: JobInfo, mqtt: MqttClient) -> Self
Creates a new Job instance with the given job information and MQTT
client.
pub async fn update(&mut self, status: JobStatus) -> Result<(), Error>
pub async fn update(&mut self, status: JobStatus) -> Result<(), Error>
Updates the status of the job to the specified status.
This function publishes a message to the
$aws/things/{thing_name}/jobs/{job_id}/update topic to update the
job execution status. It then waits for a response on the
update_accepted and update_rejected topics, and returns an error
if the request is rejected.
§Arguments
status- The new job status.
§Returns
A Result indicating the success or failure of the operation.
§Errors
This function may return the following errors:
Error::JobIdMissing- If the job ID is missing.Error::JobVersion- If the job version is missing.Error::UpdateJobRequestRejected- If the job update request is rejected.
pub async fn update_with_details(
&mut self,
status: JobStatus,
details: HashMap<String, String>,
) -> Result<(), Error>
pub async fn update_with_details( &mut self, status: JobStatus, details: HashMap<String, String>, ) -> Result<(), Error>
Updates the job with the specified status and additional details.
This function publishes a message to the
$aws/things/{thing_name}/jobs/{job_id}/update topic to update the
job execution status and details. It then waits for a response on the
update_accepted and update_rejected topics, and returns an error
if the request is rejected.
§Arguments
status- The new job status.details- A map of additional details to include in the update.
§Returns
A Result indicating the success or failure of the operation.
§Errors
This function may return the following errors:
Error::JobIdMissing- If the job ID is missing.Error::JobVersion- If the job version is missing.Error::UpdateJobRequestRejected- If the job update request is rejected.
async fn update_internal( &mut self, update_req: UpdateJobExecutionReq, ) -> Result<(), Error>
pub fn id(&self) -> Option<&str>
pub fn id(&self) -> Option<&str>
Returns the ID of the job, if it exists.
This method returns an Option<&str> that contains the job ID if it is
available, or None if the job ID is not set.
pub const fn status(&self) -> Option<&JobStatus>
pub const fn status(&self) -> Option<&JobStatus>
Returns the current status of the job, if available.
pub const fn execution_number(&self) -> Option<i64>
pub const fn execution_number(&self) -> Option<i64>
Returns the execution number of the job, if available.
The execution number represents the number of times this job has been executed. It can be useful for tracking the progress or status of a job.
pub const fn details(&self) -> Option<&HashMap<String, String>>
pub const fn details(&self) -> Option<&HashMap<String, String>>
Returns a reference to the details map associated with the job, if it exists.
The details map is a collection of key-value pairs that provide additional information about the job.
pub fn document(&self) -> Option<Value>
pub fn document(&self) -> Option<Value>
Returns a clone of the document associated with the job, if any.
pub const fn queued_at(&self) -> Option<DateTime<Utc>>
pub const fn queued_at(&self) -> Option<DateTime<Utc>>
Returns the time when the job was queued, if available.
pub const fn started_at(&self) -> Option<DateTime<Utc>>
pub const fn started_at(&self) -> Option<DateTime<Utc>>
Returns the time when the job was started, if available.
pub const fn last_updated_at(&self) -> Option<DateTime<Utc>>
pub const fn last_updated_at(&self) -> Option<DateTime<Utc>>
Returns the last time the job was updated.