JobsClient

Struct JobsClient 

pub struct JobsClient(Arc<JobsClientContainer>);
Expand description

The JobsClient struct is responsible for interacting with AWS IoT Jobs through an MQTT client.

Tuple Fields§

§0: Arc<JobsClientContainer>

Implementations§

§

impl JobsClient

pub async fn new(mqtt: MqttClient) -> Result<Self, Error>

Creates a new JobsClient instance with the provided MQTT client.

This function sets up the necessary MQTT subscriptions to handle job-related events, such as job acceptance and rejection.

§Arguments
  • mqtt - The MQTT client to use for communicating with the AWS IoT Jobs service.
§Returns

A Result containing the new JobsClient instance, or an error if the MQTT subscriptions could not be established.

pub async fn job(&self, job_id: &str) -> Result<Job, Error>

Retrieves the job for the specified job ID.

§Arguments
  • job_id - The ID of the job to retrieve.
§Returns

A Result containing the Job struct with the job execution details, or an error if the request fails.

pub async fn queued_jobs(&self) -> Result<Vec<Job>, Error>

Returns all queued jobs. It’s just a wrapper around get() but only returns the queued jobs.

§Returns

A Result containing a vector of queued Job instances.

pub async fn progress_jobs(&self) -> Result<Vec<Job>, Error>

Returns all progress jobs. It’s just a wrapper around get() but only returns the progress jobs.

§Returns

A Result containing a vector of in-progress Job instances.

pub async fn get(&self) -> Result<(Vec<Job>, Vec<Job>), Error>

Retrieves the list of pending jobs from the AWS IoT Jobs service.

This function publishes a request to the AWS IoT Jobs service to retrieve the list of pending jobs for the current device. It then waits for the response, which contains the lists of in-progress and queued jobs. The function returns these lists as a tuple.

§Errors

This function can return the following errors:

  • Error::GetJobsRejected: The request to retrieve the pending jobs was rejected by the AWS IoT Jobs service.
  • Any other errors that may occur during the MQTT communication or JSON deserialization.
§Returns

A Result containing a tuple of vectors: the first vector contains in-progress jobs, and the second vector contains queued jobs.

pub async fn start_next( &self, details: Option<HashMap<String, String>>, ) -> Result<Option<Job>, Error>

Starts the execution of the next pending job.

This function publishes a message to the $aws/things/{thing_name}/jobs/start-next topic to start the execution of the next pending job. It then waits for a response on the start_next_accepted and start_next_rejected topics, and returns the started job if the request is accepted, or an error if the request is rejected.

§Arguments
  • details - An optional map of key-value pairs to be included in the job execution.
§Returns

A Result containing the started job, or an error if the request was rejected.

Trait Implementations§

§

impl Clone for JobsClient

§

fn clone(&self) -> JobsClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for JobsClient

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl Deref for JobsClient

§

type Target = JobsClientContainer

The resulting type after dereferencing.
§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more