use std::sync::Arc; use cursive::view::{View, ViewWrapper}; use cursive::views::IdView; use cursive::Cursive; use album::Album; use artist::Artist; use commands::CommandResult; use library::Library; use queue::Queue; pub trait ListItem: Sync + Send + 'static { fn is_playing(&self, queue: Arc) -> bool; fn display_left(&self) -> String; fn display_right(&self, library: Arc) -> String; fn play(&mut self, queue: Arc); fn queue(&mut self, queue: Arc); fn toggle_saved(&mut self, library: Arc); fn open(&self, queue: Arc, library: Arc) -> Option>; fn album(&self, _queue: Arc) -> Option { None } fn artist(&self) -> Option { None } } pub trait ViewExt: View { fn title(&self) -> String { "".into() } fn on_command( &mut self, _s: &mut Cursive, _cmd: &str, _args: &[String], ) -> Result { Ok(CommandResult::Ignored) } } impl ViewExt for IdView { fn on_command( &mut self, s: &mut Cursive, cmd: &str, args: &[String], ) -> Result { self.with_view_mut(move |v| v.on_command(s, cmd, args)) .unwrap() } } pub trait IntoBoxedViewExt { fn as_boxed_view_ext(self) -> Box; } impl IntoBoxedViewExt for V { fn as_boxed_view_ext(self) -> Box { Box::new(self) } }