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
impl JobsClient
pub async fn new(mqtt: MqttClient) -> Result<Self, Error>
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 queued_jobs(&self) -> Result<Vec<Job>, Error>
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>
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>
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>
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
impl Clone for JobsClient
§fn clone(&self) -> JobsClient
fn clone(&self) -> JobsClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more