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
8a5f1e2a57
commit
3cde80b6a8
22 changed files with 323 additions and 747 deletions
|
|
@ -1,18 +1,18 @@
|
|||
pub mod error;
|
||||
pub use error::Error;
|
||||
|
||||
use glib::GString;
|
||||
use glib::{Bytes, GString};
|
||||
|
||||
pub struct Body {
|
||||
buffer: Vec<u8>,
|
||||
}
|
||||
|
||||
impl Body {
|
||||
/// Construct from response buffer
|
||||
pub fn from_response(response: &[u8] /* @TODO */) -> Result<Self, Error> {
|
||||
let start = Self::start(response)?;
|
||||
// Constructors
|
||||
pub fn from_response(bytes: &Bytes) -> Result<Self, Error> {
|
||||
let start = Self::start(bytes)?;
|
||||
|
||||
let buffer = match response.get(start..) {
|
||||
let buffer = match bytes.get(start..) {
|
||||
Some(result) => result,
|
||||
None => return Err(Error::Buffer),
|
||||
};
|
||||
|
|
@ -23,7 +23,7 @@ impl Body {
|
|||
}
|
||||
|
||||
// Getters
|
||||
pub fn buffer(&self) -> &Vec<u8> {
|
||||
pub fn buffer(&self) -> &[u8] {
|
||||
&self.buffer
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue