pub enum Task {
Enqueued {
content: EnqueuedTask,
},
Processing {
content: ProcessingTask,
},
Failed {
content: FailedTask,
},
Succeeded {
content: SucceededTask,
},
}
Variants§
Enqueued
Fields
§
content: EnqueuedTask
Processing
Fields
§
content: ProcessingTask
Failed
Fields
§
content: FailedTask
Succeeded
Fields
§
content: SucceededTask
Implementations§
Source§impl Task
impl Task
pub fn get_uid(&self) -> u32
Sourcepub async fn wait_for_completion<Http: HttpClient>(
self,
client: &Client<Http>,
interval: Option<Duration>,
timeout: Option<Duration>,
) -> Result<Self, Error>
pub async fn wait_for_completion<Http: HttpClient>( self, client: &Client<Http>, 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 { .. }));
Sourcepub fn try_make_index<Http: HttpClient>(
self,
client: &Client<Http>,
) -> Result<Index<Http>, Self>
pub fn try_make_index<Http: HttpClient>( self, client: &Client<Http>, ) -> Result<Index<Http>, Self>
Extract the Index from a successful IndexCreation
task.
If the task failed or was not an IndexCreation
task it returns 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");
Sourcepub fn unwrap_failure(self) -> MeilisearchError
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);
Sourcepub fn is_failure(&self) -> bool
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());
Sourcepub fn is_success(&self) -> bool
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());
Sourcepub fn is_pending(&self) -> bool
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<'de> Deserialize<'de> for Task
impl<'de> Deserialize<'de> for Task
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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 Freeze for Task
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more