mirror of
https://github.com/YGGverse/ggemini.git
synced 2026-03-31 17:15:31 +00:00
implement cancel action
This commit is contained in:
parent
6ee60e9d9d
commit
cdf35db0d6
2 changed files with 12 additions and 1 deletions
|
|
@ -2,7 +2,7 @@ pub mod error;
|
|||
pub use error::Error;
|
||||
|
||||
use gio::{
|
||||
prelude::{IOStreamExt, TlsConnectionExt},
|
||||
prelude::{CancellableExt, IOStreamExt, TlsConnectionExt},
|
||||
Cancellable, IOStream, NetworkAddress, SocketConnection, TlsCertificate, TlsClientConnection,
|
||||
};
|
||||
use glib::object::{Cast, IsA};
|
||||
|
|
@ -50,6 +50,15 @@ impl Connection {
|
|||
|
||||
// Actions
|
||||
|
||||
/// Apply `cancel` action to `Self` [Cancellable](https://docs.gtk.org/gio/method.Cancellable.cancel.html)
|
||||
/// * return `Error` on `Cancellable` not found
|
||||
pub fn cancel(&self) -> Result<(), Error> {
|
||||
match self.cancellable {
|
||||
Some(ref cancellable) => Ok(cancellable.cancel()),
|
||||
None => Err(Error::Cancel),
|
||||
}
|
||||
}
|
||||
|
||||
/// Close owned [SocketConnection](https://docs.gtk.org/gio/class.SocketConnection.html)
|
||||
pub fn close(&self) -> Result<(), Error> {
|
||||
match self.socket_connection.close(self.cancellable.as_ref()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue