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