update iced from 0.1 to 0.2, move periodic subscription over to the new format
This commit is contained in:
parent
1cafb91105
commit
99cec352c9
2 changed files with 2 additions and 31 deletions
|
@ -5,7 +5,7 @@ authors = ["jazzfool"]
|
|||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
iced = { version = "0.1", features = ["image", "tokio"] }
|
||||
iced = { version = "0.2", features = ["image", "tokio"] }
|
||||
iced_native = "0.2"
|
||||
gstreamer = "0.16"
|
||||
gstreamer-app = "0.16" # appsink
|
||||
|
|
31
src/lib.rs
31
src/lib.rs
|
@ -353,36 +353,7 @@ impl VideoPlayer {
|
|||
|
||||
// until iced 0.2 is released, which has this built-in
|
||||
mod time {
|
||||
use iced::futures;
|
||||
|
||||
pub fn every(duration: std::time::Duration) -> iced::Subscription<std::time::Instant> {
|
||||
iced::Subscription::from_recipe(Every(duration))
|
||||
}
|
||||
|
||||
struct Every(std::time::Duration);
|
||||
|
||||
impl<H, I> iced_native::subscription::Recipe<H, I> for Every
|
||||
where
|
||||
H: std::hash::Hasher,
|
||||
{
|
||||
type Output = std::time::Instant;
|
||||
|
||||
fn hash(&self, state: &mut H) {
|
||||
use std::hash::Hash;
|
||||
|
||||
std::any::TypeId::of::<Self>().hash(state);
|
||||
self.0.hash(state);
|
||||
}
|
||||
|
||||
fn stream(
|
||||
self: Box<Self>,
|
||||
_input: futures::stream::BoxStream<'static, I>,
|
||||
) -> futures::stream::BoxStream<'static, Self::Output> {
|
||||
use futures::stream::StreamExt;
|
||||
|
||||
tokio::time::interval(self.0)
|
||||
.map(|_| std::time::Instant::now())
|
||||
.boxed()
|
||||
}
|
||||
iced::time::every(duration)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue