thiserror, docs, remove general Failure case (#9741)

automerge
This commit is contained in:
anatoly yakovenko
2020-04-29 18:12:51 -07:00
committed by GitHub
parent 230df0ec0c
commit a0514eb2ae
8 changed files with 54 additions and 26 deletions

View File

@@ -1,11 +1,22 @@
#[derive(PartialEq, Debug)]
use thiserror::Error;
#[derive(PartialEq, Debug, Error, Eq, Clone)]
pub enum SanitizeError {
Failed,
#[error("index out of bounds")]
IndexOutOfBounds,
ValueOutOfRange,
#[error("value out of bounds")]
ValueOutOfBounds,
#[error("invalid value")]
InvalidValue,
}
/// Trait for sanitizing values and members of over the wire messages.
/// Implementation should recursively decent through the data structure
/// and sanitize all struct members and enum clauses. Sanitize excludes
/// signature verification checks, those are handled by another pass.
/// Sanitize checks should include but are not limited too:
/// * All index values are in range
/// * All values are within their static max/min bounds
pub trait Sanitize {
fn sanitize(&self) -> Result<(), SanitizeError> {
Ok(())