WIP: draft validation for flags (does not compile yet)

This commit is contained in:
Stanislav N Mikhailov
2026-08-06 16:22:28 +03:00
parent d59e9d83a4
commit 6a269ca087
2 changed files with 15 additions and 9 deletions
-1
View File
@@ -30,7 +30,6 @@ async fn main() -> io::Result<()> {
client_addr,
stream,
);
tokio::spawn(async move {
if let Err(error) = connection.run().await {
eprintln!(
+7
View File
@@ -90,18 +90,25 @@ impl Header {
///
// Валидация Header
pub fn validate(&self) -> Result<(), HeaderValidationError> {
//Валидация version
if self.version != 1 {
return Err(
HeaderValidationError::UnsupportedVersion(self.version)
);
}
// Валидация command
if self.command != 1 {
return Err(
HeaderValidationError::UnsupportedCommand(self.command)
);
}
// Валидация flags
if !(0..7).contains(&self.flags){
return Err(HeaderValidationError::UnsupportedCommand(self.flags));
};
Ok(())
}
}