handle cancellable option

This commit is contained in:
yggverse 2024-11-30 17:38:03 +02:00
parent cdf35db0d6
commit 559e03f904

View file

@ -60,10 +60,14 @@ impl Connection {
} }
/// Close owned [SocketConnection](https://docs.gtk.org/gio/class.SocketConnection.html) /// Close owned [SocketConnection](https://docs.gtk.org/gio/class.SocketConnection.html)
pub fn close(&self) -> Result<(), Error> { /// * return `Ok(false)` if `Cancellable` not defined
match self.socket_connection.close(self.cancellable.as_ref()) { pub fn close(&self) -> Result<bool, Error> {
Ok(()) => Ok(()), match self.cancellable {
Err(e) => Err(Error::SocketConnection(e)), Some(ref cancellable) => match self.socket_connection.close(Some(cancellable)) {
Ok(()) => Ok(true),
Err(e) => Err(Error::SocketConnection(e)),
},
None => Ok(false),
} }
} }