mirror of
https://github.com/YGGverse/ggemini.git
synced 2026-03-31 17:15:31 +00:00
update response namespace
This commit is contained in:
parent
70fc128c29
commit
4767929050
19 changed files with 59 additions and 50 deletions
37
src/client/connection/response.rs
Normal file
37
src/client/connection/response.rs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
//! 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
|
||||
|
||||
/// Create new `Self` from given `Connection`
|
||||
/// * useful for manual [IOStream](https://docs.gtk.org/gio/class.IOStream.html) handle (based on `Meta` bytes pre-parsed)
|
||||
pub fn from_connection_async(
|
||||
connection: Connection,
|
||||
priority: Priority,
|
||||
cancellable: 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(e) => Err(Error::Meta(e)),
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue