mirror of
https://github.com/YGGverse/ggemini.git
synced 2026-04-01 09:35:33 +00:00
initial commit
This commit is contained in:
parent
381a398de1
commit
a7083852c3
22 changed files with 446 additions and 15 deletions
26
src/client/response/header/meta.rs
Normal file
26
src/client/response/header/meta.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
pub mod error;
|
||||
pub use error::Error;
|
||||
|
||||
use glib::GString;
|
||||
|
||||
pub struct Meta {
|
||||
buffer: Vec<u8>,
|
||||
}
|
||||
|
||||
impl Meta {
|
||||
pub fn from_header(buffer: &[u8] /* @TODO */) -> Result<Self, Error> {
|
||||
let buffer = match buffer.get(2..) {
|
||||
Some(bytes) => bytes.to_vec(),
|
||||
None => return Err(Error::Undefined),
|
||||
};
|
||||
|
||||
Ok(Self { buffer })
|
||||
}
|
||||
|
||||
pub fn to_gstring(&self) -> Result<GString, Error> {
|
||||
match GString::from_utf8(self.buffer.clone()) {
|
||||
Ok(result) => Ok(result),
|
||||
Err(_) => Err(Error::Undefined),
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue