Derive defaults for sorting enums, remove ordering from films SQL query
This commit is contained in:
parent
d6bac9ebea
commit
7127dd57c6
2 changed files with 18 additions and 20 deletions
|
|
@ -24,15 +24,21 @@ pub trait MediaSorting < P : MediaProperty > : Clone + Copy + Debug + Default {
|
|||
|
||||
pub trait MediaProperty : Clone + Copy + Debug + PartialEq {}
|
||||
|
||||
# [ derive ( Clone , Copy , Debug , PartialEq ) ] pub enum FilmProperty { Name , ReleaseDate , Runtime }
|
||||
# [ derive ( Clone , Copy , Debug , PartialEq ) ] pub enum SeriesProperty { Name , FirstReleaseDate }
|
||||
# [ derive ( Clone , Copy , Debug , PartialEq ) ] pub enum SortingDirection { Ascending , Descending }
|
||||
# [ derive ( Clone , Copy , Debug , Default , PartialEq ) ] pub enum FilmProperty {
|
||||
# [default] Name , ReleaseDate , Runtime ,
|
||||
}
|
||||
# [ derive ( Clone , Copy , Debug , Default , PartialEq ) ] pub enum SeriesProperty {
|
||||
# [default] Name , FirstReleaseDate ,
|
||||
}
|
||||
# [ derive ( Clone , Copy , Debug , Default , PartialEq ) ] pub enum SortingDirection {
|
||||
# [default] Ascending , Descending ,
|
||||
}
|
||||
|
||||
# [ derive ( Clone , Copy , Debug ) ] pub struct FilmsSorting {
|
||||
# [ derive ( Clone , Copy , Debug , Default ) ] pub struct FilmsSorting {
|
||||
property : FilmProperty ,
|
||||
direction : SortingDirection ,
|
||||
}
|
||||
# [ derive ( Clone , Copy , Debug ) ] pub struct SeriesSorting {
|
||||
# [ derive ( Clone , Copy , Debug , Default ) ] pub struct SeriesSorting {
|
||||
property : SeriesProperty ,
|
||||
direction : SortingDirection ,
|
||||
}
|
||||
|
|
@ -52,19 +58,6 @@ impl MediaSorting <SeriesProperty> for SeriesSorting {
|
|||
fn get_direction ( & self ) -> SortingDirection { self . direction }
|
||||
}
|
||||
|
||||
impl Default for FilmsSorting {
|
||||
fn default () -> Self { Self {
|
||||
property : FilmProperty :: Name ,
|
||||
direction : SortingDirection :: Ascending ,
|
||||
} }
|
||||
}
|
||||
impl Default for SeriesSorting {
|
||||
fn default () -> Self { Self {
|
||||
property : SeriesProperty :: Name ,
|
||||
direction : SortingDirection :: Ascending ,
|
||||
} }
|
||||
}
|
||||
|
||||
impl MediaProperty for FilmProperty {}
|
||||
impl MediaProperty for SeriesProperty {}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue