[][src]Struct elastic_responses::bulk::BulkErrorsResponse

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, TType, TId> IsOkOnSuccess for BulkErrorsResponse<TIndex, TType, TId>[src]

impl<TIndex: Clone, TType: Clone, TId: Clone> Clone for BulkErrorsResponse<TIndex, TType, TId>[src]

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?

impl<TIndex: Debug, TType: Debug, TId: Debug> Debug for BulkErrorsResponse<TIndex, TType, TId>[src]

impl<'de, TIndex, TType, TId> Deserialize<'de> for BulkErrorsResponse<TIndex, TType, TId> where
    TIndex: Deserialize<'de>,
    TType: Deserialize<'de>,
    TId: Deserialize<'de>, 
[src]

Auto Trait Implementations

impl<TIndex, TType, TId> Send for BulkErrorsResponse<TIndex, TType, TId> where
    TId: Send,
    TIndex: Send,
    TType: Send

impl<TIndex, TType, TId> Sync for BulkErrorsResponse<TIndex, TType, TId> where
    TId: Sync,
    TIndex: Sync,
    TType: Sync

Blanket Implementations

impl<T> IsOk for T where
    T: IsOkOnSuccess
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]