pub struct ErrorTree {
pub messages: Vec<String>,
pub children: HashMap<String, ErrorTree>,
}Expand description
Hierarchical error aggregator used by validation to keep nested context.
Fields§
§messages: Vec<String>Errors at the current level.
children: HashMap<String, ErrorTree>Child errors indexed by field/key.
Implementations§
Source§impl ErrorTree
impl ErrorTree
Sourcepub fn collect<I>(iter: I) -> Result<(), ErrorTree>
pub fn collect<I>(iter: I) -> Result<(), ErrorTree>
Merge a sequence of Result values, collecting every ErrorTree into one.
Sourcepub fn add<M>(&mut self, message: M)where
M: ToString,
pub fn add<M>(&mut self, message: M)where
M: ToString,
Add an error message to the current level.
Sourcepub fn add_result<M>(&mut self, error: Result<(), M>)where
M: ToString,
pub fn add_result<M>(&mut self, error: Result<(), M>)where
M: ToString,
Push an error message only when the supplied result is Err.
Sourcepub fn add_for<K, M>(&mut self, key: K, message: M)
pub fn add_for<K, M>(&mut self, key: K, message: M)
Add an error message under a specific child key, creating nodes as needed.
Sourcepub fn merge(&mut self, other: ErrorTree)
pub fn merge(&mut self, other: ErrorTree)
Merge another ErrorTree into this one, combining children recursively.
Sourcepub fn flatten_ref(&self) -> Vec<(String, String)>
pub fn flatten_ref(&self) -> Vec<(String, String)>
Flatten the error hierarchy without consuming self.
Trait Implementations§
Source§impl CandidType for ErrorTree
impl CandidType for ErrorTree
Source§impl<'de> Deserialize<'de> for ErrorTree
impl<'de> Deserialize<'de> for ErrorTree
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ErrorTree, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ErrorTree, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for ErrorTree
impl Serialize for ErrorTree
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Eq for ErrorTree
impl StructuralPartialEq for ErrorTree
Auto Trait Implementations§
impl Freeze for ErrorTree
impl RefUnwindSafe for ErrorTree
impl Send for ErrorTree
impl Sync for ErrorTree
impl Unpin for ErrorTree
impl UnwindSafe for ErrorTree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more