mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 17:45:28 +00:00
draft new ggemini api version
This commit is contained in:
parent
920721412e
commit
1abda661a7
1 changed files with 172 additions and 179 deletions
|
|
@ -24,8 +24,7 @@ use gtk::{
|
|||
RegexMatchFlags, Uri, UriFlags,
|
||||
},
|
||||
prelude::{
|
||||
ActionExt, IOStreamExt, InputStreamExt, OutputStreamExt, SocketClientExt,
|
||||
StaticVariantType, ToVariant,
|
||||
ActionExt, IOStreamExt, OutputStreamExt, SocketClientExt, StaticVariantType, ToVariant,
|
||||
},
|
||||
Box,
|
||||
};
|
||||
|
|
@ -362,12 +361,10 @@ impl Page {
|
|||
// Private helpers @TODO
|
||||
fn load_gemini(&self, uri: Uri) {
|
||||
// Use local namespaces
|
||||
use gemini::client::{
|
||||
buffer::{Buffer, Error as BufferError},
|
||||
response::{
|
||||
use gemini::client::response::{
|
||||
body::Error as BodyError,
|
||||
header::{Mime as ClientMime, Status as ClientStatus},
|
||||
Header,
|
||||
},
|
||||
Body, Header,
|
||||
};
|
||||
|
||||
// Init shared objects (async)
|
||||
|
|
@ -423,17 +420,13 @@ impl Page {
|
|||
None::<&Cancellable>,
|
||||
move |request| match request {
|
||||
Ok(_) => {
|
||||
// Read header from response
|
||||
connection.input_stream().read_bytes_async(
|
||||
1024,
|
||||
Priority::DEFAULT,
|
||||
None::<&Cancellable>,
|
||||
move |response| match response {
|
||||
Ok(bytes) => {
|
||||
// Read header from response
|
||||
match Header::from_response(
|
||||
&bytes
|
||||
) {
|
||||
// Read header from input stream
|
||||
Header::from_socket_connection_async(
|
||||
connection.clone(),
|
||||
Some(Priority::DEFAULT),
|
||||
None::<Cancellable>,
|
||||
move |result| match result
|
||||
{
|
||||
Ok(header) => {
|
||||
// Route by status
|
||||
match header.status() {
|
||||
|
|
@ -480,7 +473,7 @@ impl Page {
|
|||
match header.mime() {
|
||||
Some(ClientMime::TextGemini) => {
|
||||
// Read entire input stream to buffer
|
||||
Buffer::from_connection_async(
|
||||
Body::from_socket_connection_async(
|
||||
connection,
|
||||
move |result|{
|
||||
match result {
|
||||
|
|
@ -515,11 +508,14 @@ impl Page {
|
|||
let status = Status::Failure;
|
||||
let title = gformat!("Oops");
|
||||
let description = match reason {
|
||||
BufferError::InputStream => match message {
|
||||
BodyError::InputStream => match message {
|
||||
Some(error) => gformat!("{error}"),
|
||||
None => gformat!("Undefined connection error")
|
||||
} ,
|
||||
BufferError::Overflow => gformat!("Buffer overflow"),
|
||||
BodyError::Overflow => gformat!("Buffer overflow"),
|
||||
BodyError::Buffer => todo!(),
|
||||
BodyError::Decode => todo!(),
|
||||
BodyError::Format => todo!(),
|
||||
};
|
||||
|
||||
// Update widget
|
||||
|
|
@ -642,9 +638,6 @@ impl Page {
|
|||
},
|
||||
Err(_) => todo!() // ResponseHeader::from_response
|
||||
}
|
||||
}
|
||||
Err(_) => todo!(), // InputStream::read_bytes_async
|
||||
},
|
||||
);
|
||||
}
|
||||
Err(_) => todo!(), // OutputStream::write_bytes_async
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue