batch_mode_batch_schema/
batch_error_data.rs1crate::ix!();
3
4#[derive(Debug)]
5pub struct BatchErrorData {
6 responses: Vec<BatchResponseRecord>,
7}
8
9impl BatchErrorData {
10
11 pub fn len(&self) -> usize {
12 self.responses.len()
13 }
14
15 pub fn new(responses: Vec<BatchResponseRecord>) -> Self {
16 Self { responses }
17 }
18
19 pub fn responses(&self) -> &Vec<BatchResponseRecord> {
20 &self.responses
21 }
22
23 pub fn request_ids(&self) -> Vec<CustomRequestId> {
24 self.responses.iter().map(|r| r.custom_id().clone()).collect()
25 }
26
27 pub fn iter(&self) -> std::slice::Iter<BatchResponseRecord> {
29 self.responses.iter()
30 }
31}
32
33impl<'a> IntoIterator for &'a BatchErrorData {
34 type Item = &'a BatchResponseRecord;
35 type IntoIter = std::slice::Iter<'a, BatchResponseRecord>;
36
37 fn into_iter(self) -> Self::IntoIter {
38 self.responses.iter()
39 }
40}
41
42impl IntoIterator for BatchErrorData {
43 type Item = BatchResponseRecord;
44 type IntoIter = std::vec::IntoIter<BatchResponseRecord>;
45
46 fn into_iter(self) -> Self::IntoIter {
47 self.responses.into_iter()
48 }
49}
50
51impl From<Vec<BatchErrorData>> for BatchErrorData {
52 fn from(batch_errors: Vec<BatchErrorData>) -> Self {
53 let aggregated_responses = batch_errors
55 .into_iter()
56 .flat_map(|error_data| error_data.responses)
57 .collect();
58 BatchErrorData::new(aggregated_responses)
59 }
60}