Include static lifetime in MediaAdapter trait, formatting
This commit is contained in:
parent
be92920cc5
commit
2c40217497
5 changed files with 162 additions and 142 deletions
|
|
@ -61,7 +61,7 @@ impl MediaSorting <SeriesProperty> for SeriesSorting {
|
|||
impl MediaProperty for FilmProperty {}
|
||||
impl MediaProperty for SeriesProperty {}
|
||||
|
||||
pub struct CollatableMediaContainer < A : MediaAdapter + 'static > {
|
||||
pub struct CollatableMediaContainer < A : MediaAdapter > {
|
||||
collated_grid : & 'static CollatedMediaGrid <A> ,
|
||||
widget : Box ,
|
||||
}
|
||||
|
|
@ -69,8 +69,8 @@ pub struct CollatableMediaContainer < A : MediaAdapter + 'static > {
|
|||
impl < A : MediaAdapter > CollatableMediaContainer <A> {
|
||||
pub fn new ( on_media_selected : impl Fn ( A :: Overview ) + 'static ) -> Self {
|
||||
let collated_grid = leak ( CollatedMediaGrid :: new (on_media_selected) ) ;
|
||||
let collation_menu = MediaCollationMenu :: new :: <A> ( |sorting|
|
||||
collated_grid . set_sorting (sorting) ,
|
||||
let collation_menu = MediaCollationMenu :: new :: <A> (
|
||||
|sorting| collated_grid . set_sorting (sorting) ,
|
||||
) ;
|
||||
|
||||
let widget = g_box ! (
|
||||
|
|
@ -90,7 +90,7 @@ impl < A : MediaAdapter > CollatableMediaContainer <A> {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait MediaAdapter {
|
||||
pub trait MediaAdapter : 'static {
|
||||
type Overview : MediaOverview ;
|
||||
type Sorting : MediaSorting < Self :: Property > ;
|
||||
type Property : MediaProperty ;
|
||||
|
|
@ -120,9 +120,12 @@ impl MediaAdapter for FilmsAdapter {
|
|||
sorting : FilmsSorting ,
|
||||
) -> Ordering {
|
||||
let ordering = match sorting . property {
|
||||
FilmProperty :: Name => film_1 . name . cmp ( & film_2 . name ) ,
|
||||
FilmProperty :: ReleaseDate => film_1 . release_date . cmp ( & film_2 . release_date ) ,
|
||||
FilmProperty :: Runtime => film_1 . runtime_minutes . cmp ( & film_2 . runtime_minutes ) ,
|
||||
FilmProperty :: Name =>
|
||||
film_1 . name . cmp ( & film_2 . name ) ,
|
||||
FilmProperty :: ReleaseDate =>
|
||||
film_1 . release_date . cmp ( & film_2 . release_date ) ,
|
||||
FilmProperty :: Runtime =>
|
||||
film_1 . runtime_minutes . cmp ( & film_2 . runtime_minutes ) ,
|
||||
} ;
|
||||
match sorting . direction {
|
||||
SortingDirection :: Ascending => ordering ,
|
||||
|
|
@ -149,8 +152,10 @@ impl MediaAdapter for SeriesAdapter {
|
|||
sorting : SeriesSorting ,
|
||||
) -> Ordering {
|
||||
let ordering = match sorting . property {
|
||||
SeriesProperty :: Name => series_1 . name . cmp ( & series_2 . name ) ,
|
||||
SeriesProperty :: FirstReleaseDate => series_1 . first_release_date . cmp ( & series_2 . first_release_date ) ,
|
||||
SeriesProperty :: Name =>
|
||||
series_1 . name . cmp ( & series_2 . name ) ,
|
||||
SeriesProperty :: FirstReleaseDate =>
|
||||
series_1 . first_release_date . cmp ( & series_2 . first_release_date ) ,
|
||||
} ;
|
||||
match sorting . direction {
|
||||
SortingDirection :: Ascending => ordering ,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue