Fix flags validation logic (compiled and verified)
This commit is contained in:
+5
-2
@@ -24,6 +24,9 @@ pub enum HeaderValidationError {
|
|||||||
|
|
||||||
#[error("Неизвестная команда протокола: {0}")]
|
#[error("Неизвестная команда протокола: {0}")]
|
||||||
UnsupportedCommand(u8),
|
UnsupportedCommand(u8),
|
||||||
|
|
||||||
|
#[error("Неизвестный набор флагов: {0}")]
|
||||||
|
UnsupportedFlagSet(u16),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -105,8 +108,8 @@ impl Header {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Валидация flags
|
// Валидация flags
|
||||||
if !(0..7).contains(&self.flags){
|
if !(0..=7).contains(&self.flags){
|
||||||
return Err(HeaderValidationError::UnsupportedCommand(self.flags));
|
return Err(HeaderValidationError::UnsupportedFlagSet (self.flags));
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user