From 44a1693e4411b173c47253ac51b49789f2c5db2e Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Fri, 2 Aug 2024 17:12:49 -0400 Subject: [PATCH] Update cursive-core to 0.4.0 `View` now require `Sync + Send`, so forward these requirements to stored callbacks. --- Cargo.toml | 4 ++-- src/infinite.rs | 13 +++++++------ src/progress.rs | 26 +++++++++++++++++++------- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4faadb4..5e7f7db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ documentation = "https://docs.rs/cursive-async-view" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -cursive_core = "0.3" +cursive_core = "0.4" log = "0.4" interpolation = "0.2" crossbeam = "0.8" @@ -23,4 +23,4 @@ lazy_static = "1.4" doc-comment = "0.3" [dev-dependencies] -cursive = "0.17.0" +cursive = "0.21.0" diff --git a/src/infinite.rs b/src/infinite.rs index 7fdadba..c249c6c 100644 --- a/src/infinite.rs +++ b/src/infinite.rs @@ -324,8 +324,9 @@ pub enum AsyncState { pub struct AsyncView { view: AsyncState, loading: TextView, - animation_fn: Box AnimationFrame + 'static>, - error_fn: Box AnimationFrame + 'static>, + animation_fn: Box AnimationFrame + Send + Sync + 'static>, + error_fn: + Box AnimationFrame + Send + Sync + 'static>, width: Option, height: Option, pos: usize, @@ -506,7 +507,7 @@ impl AsyncView { // 'static, meaning it owns all values and does not reference anything // outside of its scope. In practice this means all animation_fn must be // `move |width| {...}` or fn's. - F: Fn(usize, usize, usize) -> AnimationFrame + 'static, + F: Fn(usize, usize, usize) -> AnimationFrame + Send + Sync + 'static, { self.set_animation_fn(animation_fn); self @@ -523,7 +524,7 @@ impl AsyncView { // 'static, meaning it owns all values and does not reference anything // outside of its scope. In practice this means all animation_fn must be // `move |width| {...}` or fn's. - F: Fn(&str, usize, usize, usize, usize) -> AnimationFrame + 'static, + F: Fn(&str, usize, usize, usize, usize) -> AnimationFrame + Send + Sync + 'static, { self.set_error_fn(error_fn); self @@ -547,7 +548,7 @@ impl AsyncView { /// the previous loading animation has already started. pub fn set_animation_fn(&mut self, animation_fn: F) where - F: Fn(usize, usize, usize) -> AnimationFrame + 'static, + F: Fn(usize, usize, usize) -> AnimationFrame + Send + Sync + 'static, { self.animation_fn = Box::new(animation_fn); } @@ -560,7 +561,7 @@ impl AsyncView { /// the previous error animation has already started. pub fn set_error_fn(&mut self, error_fn: F) where - F: Fn(&str, usize, usize, usize, usize) -> AnimationFrame + 'static, + F: Fn(&str, usize, usize, usize, usize) -> AnimationFrame + Send + Sync + 'static, { self.error_fn = Box::new(error_fn); } diff --git a/src/progress.rs b/src/progress.rs index 29ad21d..6e987e2 100644 --- a/src/progress.rs +++ b/src/progress.rs @@ -260,9 +260,15 @@ pub fn default_progress_error( pub struct AsyncProgressView { view: AsyncProgressState, loading: TextView, - progress_fn: Box AnimationProgressFrame + 'static>, - error_fn: - Box AnimationProgressFrame + 'static>, + progress_fn: Box< + dyn Fn(usize, usize, f32, usize, usize) -> AnimationProgressFrame + Send + Sync + 'static, + >, + error_fn: Box< + dyn Fn(String, usize, usize, f32, usize, usize) -> AnimationProgressFrame + + Send + + Sync + + 'static, + >, width: Option, height: Option, view_rx: Receiver>, @@ -383,7 +389,7 @@ impl AsyncProgressView { /// example on how to create a custom progress function. pub fn with_progress_fn(mut self, progress_fn: F) -> Self where - F: Fn(usize, usize, f32, usize, usize) -> AnimationProgressFrame + 'static, + F: Fn(usize, usize, f32, usize, usize) -> AnimationProgressFrame + Send + Sync + 'static, { self.set_progress_fn(progress_fn); self @@ -391,7 +397,10 @@ impl AsyncProgressView { pub fn with_error_fn(mut self, error_fn: F) -> Self where - F: Fn(String, usize, usize, f32, usize, usize) -> AnimationProgressFrame + 'static, + F: Fn(String, usize, usize, f32, usize, usize) -> AnimationProgressFrame + + Send + + Sync + + 'static, { self.set_error_fn(error_fn); self @@ -415,7 +424,7 @@ impl AsyncProgressView { /// the previous progress bar has already be drawn. pub fn set_progress_fn(&mut self, progress_fn: F) where - F: Fn(usize, usize, f32, usize, usize) -> AnimationProgressFrame + 'static, + F: Fn(usize, usize, f32, usize, usize) -> AnimationProgressFrame + Send + Sync + 'static, { self.progress_fn = Box::new(progress_fn); } @@ -428,7 +437,10 @@ impl AsyncProgressView { /// the previous progress bar has already be drawn. pub fn set_error_fn(&mut self, error_fn: F) where - F: Fn(String, usize, usize, f32, usize, usize) -> AnimationProgressFrame + 'static, + F: Fn(String, usize, usize, f32, usize, usize) -> AnimationProgressFrame + + Send + + Sync + + 'static, { self.error_fn = Box::new(error_fn); }