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

Variants§

§

Enqueued

Fields

§

Processing

Fields

§

Failed

Fields

§content: FailedTask
§

Succeeded

Fields

Implementations§

source§

impl Task

source

pub fn get_uid(&self) -> u32

source

pub async fn wait_for_completion( self, client: &Client, interval: Option<Duration>, timeout: Option<Duration> ) -> Result<Self, Error>

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 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 { .. }));
source

pub fn try_make_index(self, client: &Client) -> Result<Index, Self>

Extract the Index from a successful IndexCreation task.

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

Example
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");
source

pub fn unwrap_failure(self) -> MeilisearchError

Unwrap the MeilisearchError from a Self::Failed Task.

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

Example
let task = client.create_index("unwrap_failure", None).await.unwrap();
let task = client
    .create_index("unwrap_failure", None)
    .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::IndexAlreadyExists);
source

pub fn is_failure(&self) -> bool

Returns true if the Task is Self::Failed.

Example
let task = client.create_index("is_failure", None).await.unwrap();
// create an index with a conflicting uid
let task = client
    .create_index("is_failure", None)
    .await
    .unwrap()
    .wait_for_completion(&client, None, None)
    .await
    .unwrap();

assert!(task.is_failure());
source

pub fn is_success(&self) -> bool

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());
source

pub fn is_pending(&self) -> bool

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§

source§

impl AsRef<u32> for Task

source§

fn as_ref(&self) -> &u32

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

impl Clone for Task

source§

fn clone(&self) -> Task

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Task

source§

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

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Task

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Task

§

impl Send for Task

§

impl Sync for Task

§

impl Unpin for Task

§

impl UnwindSafe for Task

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

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

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T> Instrument for T

source§

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

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

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 Twhere 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<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,