mirror of
https://github.com/YGGverse/ggemini.git
synced 2026-03-31 17:15:31 +00:00
fix route by first byte
This commit is contained in:
parent
788b792167
commit
a5fbca2ace
4 changed files with 15 additions and 15 deletions
|
|
@ -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),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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}")
|
||||
|
|
|
|||
|
|
@ -22,15 +22,15 @@ impl Failure {
|
|||
pub fn from_utf8(buffer: &[u8]) -> Result<Self, Error> {
|
||||
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),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue