From a5fbca2ace7d3556692eba1e34d0d915a5806889 Mon Sep 17 00:00:00 2001 From: yggverse Date: Mon, 3 Feb 2025 01:20:08 +0200 Subject: [PATCH] fix route by first byte --- src/client/connection/response.rs | 12 ++++++------ src/client/connection/response/error.rs | 6 +++--- src/client/connection/response/failure.rs | 6 +++--- src/client/connection/response/failure/error.rs | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/client/connection/response.rs b/src/client/connection/response.rs index adaf209..9c66dd3 100644 --- a/src/client/connection/response.rs +++ b/src/client/connection/response.rs @@ -48,27 +48,27 @@ impl Response { match result { Ok(buffer) => match buffer.first() { Some(byte) => match byte { - 1 => match Input::from_utf8(&buffer) { + 0x31 => match Input::from_utf8(&buffer) { Ok(input) => Ok(Self::Input(input)), Err(e) => Err(Error::Input(e)), }, - 2 => match Success::from_utf8(&buffer) { + 0x32 => match Success::from_utf8(&buffer) { Ok(success) => Ok(Self::Success(success)), Err(e) => Err(Error::Success(e)), }, - 3 => match Redirect::from_utf8(&buffer) { + 0x33 => match Redirect::from_utf8(&buffer) { Ok(redirect) => Ok(Self::Redirect(redirect)), Err(e) => Err(Error::Redirect(e)), }, - 4 | 5 => match Failure::from_utf8(&buffer) { + 0x34 | 0x35 => match Failure::from_utf8(&buffer) { Ok(failure) => Ok(Self::Failure(failure)), Err(e) => Err(Error::Failure(e)), }, - 6 => match Certificate::from_utf8(&buffer) { + 0x36 => match Certificate::from_utf8(&buffer) { Ok(certificate) => Ok(Self::Certificate(certificate)), Err(e) => Err(Error::Certificate(e)), }, - b => Err(Error::Code(*b)), + _ => Err(Error::Code), }, None => Err(Error::Protocol), }, diff --git a/src/client/connection/response/error.rs b/src/client/connection/response/error.rs index 99895d9..df8cda4 100644 --- a/src/client/connection/response/error.rs +++ b/src/client/connection/response/error.rs @@ -6,7 +6,7 @@ use std::{ #[derive(Debug)] pub enum Error { Certificate(super::certificate::Error), - Code(u8), + Code, Failure(super::failure::Error), Input(super::input::Error), Protocol, @@ -22,8 +22,8 @@ impl Display for Error { Self::Certificate(e) => { write!(f, "Certificate error: {e}") } - Self::Code(e) => { - write!(f, "Code group error: {e}*") + Self::Code => { + write!(f, "Code group error") } Self::Failure(e) => { write!(f, "Failure error: {e}") diff --git a/src/client/connection/response/failure.rs b/src/client/connection/response/failure.rs index c0e76ec..19f6461 100644 --- a/src/client/connection/response/failure.rs +++ b/src/client/connection/response/failure.rs @@ -22,15 +22,15 @@ impl Failure { pub fn from_utf8(buffer: &[u8]) -> Result { match buffer.first() { Some(byte) => match byte { - 4 => match Temporary::from_utf8(buffer) { + 0x34 => match Temporary::from_utf8(buffer) { Ok(input) => Ok(Self::Temporary(input)), Err(e) => Err(Error::Temporary(e)), }, - 5 => match Permanent::from_utf8(buffer) { + 0x35 => match Permanent::from_utf8(buffer) { Ok(failure) => Ok(Self::Permanent(failure)), Err(e) => Err(Error::Permanent(e)), }, - b => Err(Error::Code(*b)), + _ => Err(Error::Code), }, None => Err(Error::Protocol), } diff --git a/src/client/connection/response/failure/error.rs b/src/client/connection/response/failure/error.rs index 60724eb..7725b92 100644 --- a/src/client/connection/response/failure/error.rs +++ b/src/client/connection/response/failure/error.rs @@ -2,7 +2,7 @@ use std::fmt::{Display, Formatter, Result}; #[derive(Debug)] pub enum Error { - Code(u8), + Code, Permanent(super::permanent::Error), Protocol, Temporary(super::temporary::Error), @@ -11,8 +11,8 @@ pub enum Error { impl Display for Error { fn fmt(&self, f: &mut Formatter) -> Result { match self { - Self::Code(e) => { - write!(f, "Code group error: {e}*") + Self::Code => { + write!(f, "Code group error") } Self::Permanent(e) => { write!(f, "Permanent failure group error: {e}")