mirror of
https://github.com/YGGverse/ggemini.git
synced 2026-04-01 01:25:32 +00:00
draft new api version
This commit is contained in:
parent
67d486cc4d
commit
3a9e84a3d9
19 changed files with 490 additions and 87 deletions
|
|
@ -1,6 +1,35 @@
|
|||
//! Read and parse Gemini response as Object
|
||||
|
||||
pub mod data;
|
||||
pub mod error;
|
||||
pub mod meta;
|
||||
|
||||
pub use error::Error;
|
||||
pub use meta::Meta;
|
||||
|
||||
use super::Connection;
|
||||
use gio::Cancellable;
|
||||
use glib::Priority;
|
||||
|
||||
pub struct Response {
|
||||
pub connection: Connection,
|
||||
pub meta: Meta,
|
||||
}
|
||||
|
||||
impl Response {
|
||||
// Constructors
|
||||
|
||||
pub fn from_request_async(
|
||||
connection: Connection,
|
||||
priority: Option<Priority>,
|
||||
cancellable: Option<Cancellable>,
|
||||
callback: impl FnOnce(Result<Self, Error>) + 'static,
|
||||
) {
|
||||
Meta::from_stream_async(connection.stream(), priority, cancellable, |result| {
|
||||
callback(match result {
|
||||
Ok(meta) => Ok(Self { connection, meta }),
|
||||
Err(reason) => Err(Error::Meta(reason)),
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue