mirror of
https://github.com/YGGverse/ggemini.git
synced 2026-04-01 17:45:35 +00:00
draft new api version
This commit is contained in:
parent
dccff1e111
commit
9152528790
17 changed files with 299 additions and 317 deletions
|
|
@ -1,7 +1,7 @@
|
|||
pub mod error;
|
||||
pub use error::Error;
|
||||
|
||||
use glib::{Bytes, GString};
|
||||
use glib::GString;
|
||||
|
||||
/// Entire meta buffer, but [status code](https://geminiprotocol.net/docs/protocol-specification.gmi#status-codes).
|
||||
///
|
||||
|
|
@ -11,13 +11,13 @@ pub struct Meta {
|
|||
}
|
||||
|
||||
impl Meta {
|
||||
pub fn from_header(bytes: &Bytes) -> Result<Self, Error> {
|
||||
let buffer = match bytes.get(3..) {
|
||||
Some(bytes) => bytes.to_vec(),
|
||||
pub fn from_header(buffer: &[u8]) -> Result<Self, Error> {
|
||||
match buffer.get(3..) {
|
||||
Some(value) => Ok(Self {
|
||||
buffer: value.to_vec(),
|
||||
}),
|
||||
None => return Err(Error::Undefined),
|
||||
};
|
||||
|
||||
Ok(Self { buffer })
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_gstring(&self) -> Result<GString, Error> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue