mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-02-05 16:04:15 +00:00
use ByteBuffer::read_input_stream_async API
This commit is contained in:
parent
35e0e2d47d
commit
b867eb596f
@ -20,8 +20,8 @@ use gtk::{
|
|||||||
Uri, UriFlags,
|
Uri, UriFlags,
|
||||||
},
|
},
|
||||||
prelude::{
|
prelude::{
|
||||||
ActionExt, IOStreamExt, InputStreamExtManual, OutputStreamExtManual, SocketClientExt,
|
ActionExt, IOStreamExt, OutputStreamExtManual, SocketClientExt, StaticVariantType,
|
||||||
StaticVariantType, ToVariant,
|
ToVariant,
|
||||||
},
|
},
|
||||||
Box,
|
Box,
|
||||||
};
|
};
|
||||||
@ -235,24 +235,30 @@ impl Page {
|
|||||||
|
|
||||||
action_update.activate(Some(&id));
|
action_update.activate(Some(&id));
|
||||||
|
|
||||||
// Read response
|
// Define local NS
|
||||||
connection.input_stream().read_all_async(
|
use gemini::client::{
|
||||||
vec![0; 0xfffff], // 1Mb @TODO
|
connection::input_stream::ByteBuffer,
|
||||||
Priority::DEFAULT,
|
response::{
|
||||||
Some(&cancellable.clone()),
|
header::{
|
||||||
move |i| match i {
|
Mime as ResponseMime,
|
||||||
Ok(i) => {
|
Status as ResponseStatus
|
||||||
// Define local NS
|
},
|
||||||
use gemini::client::response::{
|
Response,
|
||||||
header::{
|
}
|
||||||
Mime as ResponseMime,
|
};
|
||||||
Status as ResponseStatus
|
|
||||||
},
|
|
||||||
Response,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
// Read response
|
||||||
|
ByteBuffer::new().read_input_stream_async(
|
||||||
|
connection.input_stream(),
|
||||||
|
cancellable.clone(),
|
||||||
|
Priority::DEFAULT,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
move |i| {
|
||||||
|
match i {
|
||||||
|
Ok(buffer) => {
|
||||||
match Response::from_utf8(
|
match Response::from_utf8(
|
||||||
&i.0.to_vec(),
|
&buffer.to_utf8(),
|
||||||
) {
|
) {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
// Format response
|
// Format response
|
||||||
@ -447,11 +453,11 @@ impl Page {
|
|||||||
todo!("Error closing connection: {}", error.message());
|
todo!("Error closing connection: {}", error.message());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(error) => {
|
Err(_) => {
|
||||||
// Define common data
|
// Define common data
|
||||||
let status = Status::Failure;
|
let status = Status::Failure;
|
||||||
let title = gformat!("Oops");
|
let title = gformat!("Oops");
|
||||||
let description = gformat!("Failed to read response: {}", error.1.message());
|
let description = gformat!("Failed to read response");
|
||||||
|
|
||||||
// Update widget
|
// Update widget
|
||||||
content.set_status_failure(title.as_str(), description.as_str());
|
content.set_status_failure(title.as_str(), description.as_str());
|
||||||
@ -469,6 +475,7 @@ impl Page {
|
|||||||
todo!("Error closing response connection: {}", error.message());
|
todo!("Error closing response connection: {}", error.message());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user