Struct elastic_responses::bulk::BulkErrorsResponse
[−]
[src]
pub struct BulkErrorsResponse<TIndex = String, TType = String, TId = String> { /* fields omitted */ }
Response for a bulk request.
This type only accumulates bulk items that failed.
It can be more efficient if you only care about errors.
Individual bulk items are ErrorItem
and can be iterated over.
Examples
Send a bulk request and iterate through the errors:
let response: BulkErrorsResponse = do_request(); // Do something with failed items for item in response { match item.action() { Action::Delete => (), // Ignore failed deletes _ => println!("err: {:?}", item) } }
Use iter
to iterate over individual errors without taking ownership of them:
let response: BulkErrorsResponse = do_request(); // Do something with errors for index `myindex` let item_iter = response.iter() .filter(|o| o.index() == "myindex"); for item in item_iter { println!("err: {:?}", item); }
Taking BulkErrorsResponse
as an argument
The BulkErrorsResponse
type has three default generic parameters for the index, type and id fields.
If you need to accept a BulkErrorsResponse
as a function argument, you should specify these generics.
Otherwise the function will only accept a default BulkErrorsResponse
:
// Do: Supports any BulkErrorsResponse fn takes_any_response<TIndex, TType, TId>(res: BulkErrorsResponse<TIndex, TType, TId>) { } // Don't: Only supports default BulkErrorsResponse fn takes_default_response(res: BulkErrorsResponse) { }
Methods
impl<TIndex, TType, TId> BulkErrorsResponse<TIndex, TType, TId>
[src]
pub fn took(&self) -> u64
[src]
Time in milliseconds it took for Elasticsearch to process the request.
pub fn is_ok(&self) -> bool
[src]
Returns true
if all bulk items succeeded.
pub fn is_err(&self) -> bool
[src]
Returns true
if any bulk itemss failed.
ⓘImportant traits for ErrorIter<'a, TIndex, TType, TId>pub fn iter(&self) -> ErrorIter<TIndex, TType, TId>
[src]
Iterate through the bulk item errors.
Items in this iterator all all errors that occurred while handling the bulk request.
Examples
Iterate through the individual items in a BulkErrorsResponse
:
let response: BulkErrorsResponse = do_request(); // Iterate through all items for item in response.iter() { // Do something with failed items println!("err: {:?}", item) }
Trait Implementations
impl<TIndex: Debug, TType: Debug, TId: Debug> Debug for BulkErrorsResponse<TIndex, TType, TId>
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<TIndex: Clone, TType: Clone, TId: Clone> Clone for BulkErrorsResponse<TIndex, TType, TId>
[src]
fn clone(&self) -> BulkErrorsResponse<TIndex, TType, TId>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<TIndex, TType, TId> IntoIterator for BulkErrorsResponse<TIndex, TType, TId>
[src]
type Item = <Self::IntoIter as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = ErrorIntoIter<TIndex, TType, TId>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
Creates an iterator from a value. Read more
impl<TIndex, TType, TId> IsOk for BulkErrorsResponse<TIndex, TType, TId>
[src]
fn is_ok<B: ResponseBody>(
head: HttpResponseHead,
body: Unbuffered<B>
) -> Result<MaybeOkResponse<B>, ParseResponseError>
[src]
head: HttpResponseHead,
body: Unbuffered<B>
) -> Result<MaybeOkResponse<B>, ParseResponseError>
Inspect the http response to determine whether or not it succeeded.
Auto Trait Implementations
impl<TIndex, TType, TId> Send for BulkErrorsResponse<TIndex, TType, TId> where
TId: Send,
TIndex: Send,
TType: Send,
TId: Send,
TIndex: Send,
TType: Send,
impl<TIndex, TType, TId> Sync for BulkErrorsResponse<TIndex, TType, TId> where
TId: Sync,
TIndex: Sync,
TType: Sync,
TId: Sync,
TIndex: Sync,
TType: Sync,