Skip to content

Commit d018caa

Browse files
gio: Make GioFuture handle infaliable futures
1 parent 6961ee4 commit d018caa

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

gio/src/gio_future.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,29 @@ use std::pin::{self, Pin};
1111
use crate::prelude::*;
1212
use crate::Cancellable;
1313

14-
pub struct GioFuture<F, O, T, E> {
14+
pub struct GioFuture<F, O, T> {
1515
obj: O,
1616
schedule_operation: Option<F>,
1717
cancellable: Option<Cancellable>,
18-
receiver: Option<oneshot::Receiver<Result<T, E>>>,
18+
receiver: Option<oneshot::Receiver<T>>,
1919
}
2020

21-
pub struct GioFutureResult<T, E> {
22-
sender: oneshot::Sender<Result<T, E>>,
21+
pub struct GioFutureResult<T> {
22+
sender: oneshot::Sender<T>,
2323
}
2424

25-
impl<T, E> GioFutureResult<T, E> {
26-
pub fn resolve(self, res: Result<T, E>) {
25+
impl<T> GioFutureResult<T> {
26+
pub fn resolve(self, res: T) {
2727
let _ = self.sender.send(res);
2828
}
2929
}
3030

31-
impl<F, O, T: 'static, E: 'static> GioFuture<F, O, T, E>
31+
impl<F, O, T: 'static> GioFuture<F, O, T>
3232
where
3333
O: Clone + 'static,
34-
F: FnOnce(&O, &Cancellable, GioFutureResult<T, E>) + 'static,
34+
F: FnOnce(&O, &Cancellable, GioFutureResult<T>) + 'static,
3535
{
36-
pub fn new(obj: &O, schedule_operation: F) -> GioFuture<F, O, T, E> {
36+
pub fn new(obj: &O, schedule_operation: F) -> GioFuture<F, O, T> {
3737
GioFuture {
3838
obj: obj.clone(),
3939
schedule_operation: Some(schedule_operation),
@@ -43,14 +43,14 @@ where
4343
}
4444
}
4545

46-
impl<F, O, T, E> Future for GioFuture<F, O, T, E>
46+
impl<F, O, T> Future for GioFuture<F, O, T>
4747
where
4848
O: Clone + 'static,
49-
F: FnOnce(&O, &Cancellable, GioFutureResult<T, E>) + 'static,
49+
F: FnOnce(&O, &Cancellable, GioFutureResult<T>) + 'static,
5050
{
51-
type Output = Result<T, E>;
51+
type Output = T;
5252

53-
fn poll(mut self: pin::Pin<&mut Self>, ctx: &mut Context) -> Poll<Result<T, E>> {
53+
fn poll(mut self: pin::Pin<&mut Self>, ctx: &mut Context) -> Poll<T> {
5454
let GioFuture {
5555
ref obj,
5656
ref mut schedule_operation,
@@ -103,10 +103,10 @@ where
103103
}
104104
}
105105

106-
impl<F, O, T, E> FusedFuture for GioFuture<F, O, T, E>
106+
impl<F, O, T> FusedFuture for GioFuture<F, O, T>
107107
where
108108
O: Clone + 'static,
109-
F: FnOnce(&O, &Cancellable, GioFutureResult<T, E>) + 'static,
109+
F: FnOnce(&O, &Cancellable, GioFutureResult<T>) + 'static,
110110
{
111111
fn is_terminated(&self) -> bool {
112112
self.schedule_operation.is_none()
@@ -117,7 +117,7 @@ where
117117
}
118118
}
119119

120-
impl<F, O, T, E> Drop for GioFuture<F, O, T, E> {
120+
impl<F, O, T> Drop for GioFuture<F, O, T> {
121121
fn drop(&mut self) {
122122
if let Some(cancellable) = self.cancellable.take() {
123123
cancellable.cancel();
@@ -126,4 +126,4 @@ impl<F, O, T, E> Drop for GioFuture<F, O, T, E> {
126126
}
127127
}
128128

129-
impl<F, O, T, E> Unpin for GioFuture<F, O, T, E> {}
129+
impl<F, O, T> Unpin for GioFuture<F, O, T> {}

gio/src/subclass/async_initable.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl<T: AsyncInitableImpl> AsyncInitableImplExt for T {
6262
.init_finish
6363
.expect("no parent \"init_finish\" implementation");
6464

65-
let r: Box<ThreadGuard<GioFutureResult<(), Error>>> =
65+
let r: Box<ThreadGuard<GioFutureResult<Result<(), Error>>>> =
6666
Box::from_raw(user_data as *mut _);
6767
let r = r.into_inner();
6868

@@ -79,7 +79,7 @@ impl<T: AsyncInitableImpl> AsyncInitableImplExt for T {
7979
Box::pin(crate::GioFuture::new(
8080
&*self.obj(),
8181
move |obj, cancellable, res| {
82-
let user_data: Box<ThreadGuard<GioFutureResult<(), Error>>> =
82+
let user_data: Box<ThreadGuard<GioFutureResult<Result<(), Error>>>> =
8383
Box::new(ThreadGuard::new(res));
8484
let user_data = Box::into_raw(user_data);
8585
init_async(

0 commit comments

Comments
 (0)