pub enum Task {
    Enqueued {
        content: EnqueuedTask,
    },
    Processing {
        content: EnqueuedTask,
    },
    Failed {
        content: FailedTask,
    },
    Succeeded {
        content: SucceededTask,
    },
}

Variants

Enqueued

Fields

content: EnqueuedTask

Processing

Fields

content: EnqueuedTask

Failed

Fields

content: FailedTask

Succeeded

Fields

content: SucceededTask

Implementations

Wait until Meilisearch processes a Task, and get its status.

interval = The frequency at which the server should be polled. Default = 50ms timeout = The maximum time to wait for processing to complete. Default = 5000ms

If the waited time exceeds timeout then an Error::Timeout will be returned.

See also [Client::wait_for_task, Index::wait_for_task].

Example
let client = Client::new(MEILISEARCH_HOST, MEILISEARCH_API_KEY);
let movies = client.index("movies_wait_for_completion");

let status = movies.add_documents(&[
    Document { id: 0, kind: "title".into(), value: "The Social Network".to_string() },
    Document { id: 1, kind: "title".into(), value: "Harry Potter and the Sorcerer's Stone".to_string() },
], None)
  .await
  .unwrap()
  .wait_for_completion(&client, None, None)
  .await
  .unwrap();

assert!(matches!(status, Task::Succeeded { .. }));

Extract the Index from a successful IndexCreation task.

If the task failed or was not an IndexCreation task it return itself.

Example
// create the client
let client = Client::new(MEILISEARCH_HOST, MEILISEARCH_API_KEY);

let task = client.create_index("try_make_index", None).await.unwrap();
let index = client.wait_for_task(task, None, None).await.unwrap().try_make_index(&client).unwrap();

// and safely access it
assert_eq!(index.as_ref(), "try_make_index");

Unwrap the MeilisearchError from a Self::Failed Task.

Will panic if the task was not Self::Failed.

Example

let task = index.set_ranking_rules(["wrong_ranking_rule"])
  .await
  .unwrap()
  .wait_for_completion(&client, None, None)
  .await
  .unwrap();

assert!(task.is_failure());

let failure = task.unwrap_failure();

assert_eq!(failure.error_code, ErrorCode::InvalidRankingRule);

Returns true if the Task is Self::Failed.

Example


let task = index.set_ranking_rules(["wrong_ranking_rule"])
  .await
  .unwrap()
  .wait_for_completion(&client, None, None)
  .await
  .unwrap();

assert!(task.is_failure());

Returns true if the Task is Self::Succeeded.

Example
let task = client
  .create_index("is_success", None)
  .await
  .unwrap()
  .wait_for_completion(&client, None, None)
  .await
  .unwrap();

assert!(task.is_success());

Returns true if the Task is pending (Self::Enqueued or Self::Processing).

Example
let task_info = client
  .create_index("is_pending", None)
  .await
  .unwrap();
let task = client.get_task(task_info).await.unwrap();
assert!(task.is_pending());

Trait Implementations

Converts this type into a shared reference of the (usually inferred) input type.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

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

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

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

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

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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

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

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

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