mirror of
https://github.com/YGGverse/ggemini.git
synced 2026-03-31 17:15:31 +00:00
remove extra conversions
This commit is contained in:
parent
5dd78dd43d
commit
b5be9dcc76
2 changed files with 3 additions and 5 deletions
|
|
@ -4,8 +4,6 @@
|
|||
pub mod error;
|
||||
pub use error::Error;
|
||||
|
||||
use glib::GString;
|
||||
|
||||
/// Holder for [status code](https://geminiprotocol.net/docs/protocol-specification.gmi#status-codes)
|
||||
#[derive(Debug)]
|
||||
pub enum Status {
|
||||
|
|
@ -70,8 +68,8 @@ impl Status {
|
|||
/// * includes `Self::from_string` parser, it means that given buffer should contain some **header**
|
||||
pub fn from_utf8(buffer: &[u8]) -> Result<Self, Error> {
|
||||
match buffer.get(0..2) {
|
||||
Some(value) => match GString::from_utf8(value.to_vec()) {
|
||||
Ok(string) => Self::from_string(string.as_str()),
|
||||
Some(value) => match std::str::from_utf8(value) {
|
||||
Ok(s) => Self::from_string(s),
|
||||
Err(e) => Err(Error::Decode(e)),
|
||||
},
|
||||
None => Err(Error::Protocol),
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use std::fmt::{Display, Formatter, Result};
|
|||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
Decode(std::string::FromUtf8Error),
|
||||
Decode(std::str::Utf8Error),
|
||||
Protocol,
|
||||
Undefined,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue