Skip to content

Commit 6e7c200

Browse files
committed
gdk-pixbuf: Return a Option<Duration> from AnimationIter::delay_time()
It's a duration in milliseconds or -1 and the `Impl` trait already used an `Option<Duration>` here.
1 parent 22a91c1 commit 6e7c200

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

gdk-pixbuf/src/pixbuf_animation_iter.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Take a look at the license at the top of the repository in the LICENSE file.
22

3-
use std::time::SystemTime;
3+
use std::time::{Duration, SystemTime};
44

55
use glib::translate::*;
66

@@ -45,8 +45,16 @@ impl PixbufAnimationIter {
4545

4646
#[doc(alias = "gdk_pixbuf_animation_iter_get_delay_time")]
4747
#[doc(alias = "get_delay_time")]
48-
pub fn delay_time(&self) -> i32 {
49-
unsafe { ffi::gdk_pixbuf_animation_iter_get_delay_time(self.to_glib_none().0) }
48+
pub fn delay_time(&self) -> Option<Duration> {
49+
unsafe {
50+
let res = ffi::gdk_pixbuf_animation_iter_get_delay_time(self.to_glib_none().0);
51+
52+
if res < 0 {
53+
None
54+
} else {
55+
Some(Duration::from_millis(res as u64))
56+
}
57+
}
5058
}
5159

5260
#[doc(alias = "gdk_pixbuf_animation_iter_on_currently_loading_frame")]

0 commit comments

Comments
 (0)