From b5be9dcc76e24e2493ea2f0d31fb28fdf54c967a Mon Sep 17 00:00:00 2001 From: yggverse Date: Sat, 18 Jan 2025 02:53:33 +0200 Subject: [PATCH] remove extra conversions --- src/client/connection/response/meta/status.rs | 6 ++---- src/client/connection/response/meta/status/error.rs | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/client/connection/response/meta/status.rs b/src/client/connection/response/meta/status.rs index 8f688c6..6f11ee4 100644 --- a/src/client/connection/response/meta/status.rs +++ b/src/client/connection/response/meta/status.rs @@ -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 { 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), diff --git a/src/client/connection/response/meta/status/error.rs b/src/client/connection/response/meta/status/error.rs index b535376..24090dd 100644 --- a/src/client/connection/response/meta/status/error.rs +++ b/src/client/connection/response/meta/status/error.rs @@ -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, }