Enum meilisearch_sdk::tasks::Task
source · [−]pub enum Task {
Enqueued {
content: EnqueuedTask,
},
Processing {
content: EnqueuedTask,
},
Failed {
content: FailedTask,
},
Succeeded {
content: ProcessedTask,
},
}Variants
Enqueued
Fields
content: EnqueuedTaskProcessing
Fields
content: EnqueuedTaskFailed
Fields
content: FailedTaskSucceeded
Fields
content: ProcessedTaskImplementations
sourceimpl Task
impl Task
pub fn get_uid(&self) -> u64
sourcepub async fn wait_for_completion(
self,
client: &Client,
interval: Option<Duration>,
timeout: Option<Duration>
) -> Result<Self, Error>
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 client = Client::new("http://localhost:7700", "masterKey");
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(self, client: &Client) -> Result<Index, Self>
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
// create the client
let client = Client::new("http://localhost:7700", "masterKey");
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 = 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);sourcepub fn is_failure(&self) -> bool
pub fn is_failure(&self) -> bool
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());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 = client
.create_index("is_pending", None)
.await
.unwrap();
assert!(task.is_pending());Trait Implementations
sourceimpl<'de> Deserialize<'de> for Task
impl<'de> Deserialize<'de> for Task
sourcefn 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 RefUnwindSafe for Task
impl Send for Task
impl Sync for Task
impl Unpin for Task
impl UnwindSafe for Task
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more