forked from mongodb/mongo-rust-driver
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patherror.rs
32 lines (28 loc) · 1023 Bytes
/
error.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use std::collections::HashMap;
use crate::{
error::{WriteConcernError, WriteError},
results::BulkWriteResult,
};
#[derive(Clone, Debug, Default)]
#[non_exhaustive]
pub struct BulkWriteError {
pub write_concern_errors: Vec<WriteConcernError>,
pub write_errors: HashMap<usize, WriteError>,
pub partial_result: Option<BulkWriteResult>,
}
impl BulkWriteError {
pub(crate) fn merge(&mut self, other: BulkWriteError) {
self.write_concern_errors.extend(other.write_concern_errors);
self.write_errors.extend(other.write_errors);
if let Some(other_partial_result) = other.partial_result {
self.merge_partial_results(other_partial_result);
}
}
pub(crate) fn merge_partial_results(&mut self, other_partial_result: BulkWriteResult) {
if let Some(ref mut partial_result) = self.partial_result {
partial_result.merge(other_partial_result);
} else {
self.partial_result = Some(other_partial_result);
}
}
}