mirror of
https://github.com/YGGverse/ggemini.git
synced 2026-04-01 09:35:33 +00:00
draft new api version
This commit is contained in:
parent
8a5f1e2a57
commit
3cde80b6a8
22 changed files with 323 additions and 747 deletions
|
|
@ -1,15 +1,18 @@
|
|||
pub mod error;
|
||||
pub use error::Error;
|
||||
|
||||
use glib::GString;
|
||||
use glib::{Bytes, GString};
|
||||
|
||||
/// Entire meta buffer, but [status code](https://geminiprotocol.net/docs/protocol-specification.gmi#status-codes).
|
||||
///
|
||||
/// Usefult to grab placeholder text on 10, 11, 31 codes processing
|
||||
pub struct Meta {
|
||||
buffer: Vec<u8>,
|
||||
}
|
||||
|
||||
impl Meta {
|
||||
pub fn from_header(buffer: &[u8] /* @TODO */) -> Result<Self, Error> {
|
||||
let buffer = match buffer.get(2..) {
|
||||
pub fn from_header(bytes: &Bytes) -> Result<Self, Error> {
|
||||
let buffer = match bytes.get(3..) {
|
||||
Some(bytes) => bytes.to_vec(),
|
||||
None => return Err(Error::Undefined),
|
||||
};
|
||||
|
|
@ -23,4 +26,8 @@ impl Meta {
|
|||
Err(_) => Err(Error::Undefined),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn buffer(&self) -> &[u8] {
|
||||
&self.buffer
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue