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,9 +1,10 @@
|
|||
pub mod error;
|
||||
pub use error::Error;
|
||||
|
||||
use glib::{Bytes, GString};
|
||||
use glib::GString;
|
||||
|
||||
/// https://geminiprotocol.net/docs/protocol-specification.gmi#status-codes
|
||||
#[derive(Debug)]
|
||||
pub enum Status {
|
||||
Input,
|
||||
SensitiveInput,
|
||||
|
|
@ -12,9 +13,9 @@ pub enum Status {
|
|||
} // @TODO
|
||||
|
||||
impl Status {
|
||||
pub fn from_header(bytes: &Bytes) -> Result<Self, Error> {
|
||||
match bytes.get(0..2) {
|
||||
Some(bytes) => match GString::from_utf8(bytes.to_vec()) {
|
||||
pub fn from_header(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()),
|
||||
Err(_) => Err(Error::Decode),
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue