Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
elomatreb committed Feb 1, 2024
1 parent 0ac950c commit 33b4a72
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions mpd_client/src/commands/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl Queue {
/// Info for the given song
pub fn song<S>(song: S) -> QueueRange
where
S: Into<Song>
S: Into<Song>,
{
QueueRange(SongOrSongRange::Single(song.into()))
}
Expand Down Expand Up @@ -234,7 +234,7 @@ enum SongOrSongRange {
Single(Song),

/// Song Range
Range(SongRange)
Range(SongRange),
}

/// `playlistinfo` / 'playlistid' commands for single songs / song ranges
Expand All @@ -245,7 +245,7 @@ impl QueueRange {
/// Info for the given song
pub fn song<S>(song: S) -> Self
where
S: Into<Song>
S: Into<Song>,
{
Self(SongOrSongRange::Single(song.into()))
}
Expand All @@ -267,10 +267,11 @@ impl Command for QueueRange {
fn command(&self) -> RawCommand {
match self.0 {
SongOrSongRange::Single(Song::Id(id)) => RawCommand::new("playlistid").argument(id),
SongOrSongRange::Single(Song::Position(pos)) => RawCommand::new("playlistinfo").argument(pos),
SongOrSongRange::Range(range) => RawCommand::new("playlistinfo").argument(range)
SongOrSongRange::Single(Song::Position(pos)) => {
RawCommand::new("playlistinfo").argument(pos)
}
SongOrSongRange::Range(range) => RawCommand::new("playlistinfo").argument(range),
}

}

fn response(self, frame: Frame) -> Result<Self::Response, TypedResponseError> {
Expand Down Expand Up @@ -512,7 +513,7 @@ impl Command for Shuffle {
fn command(&self) -> RawCommand {
match self.0 {
None => RawCommand::new("shuffle"),
Some(range) => RawCommand::new("shuffle").argument(range)
Some(range) => RawCommand::new("shuffle").argument(range),
}
}

Expand Down Expand Up @@ -1770,9 +1771,18 @@ mod tests {
#[test]
fn command_queue() {
assert_eq!(Queue.command(), RawCommand::new("playlistinfo"));
assert_eq!(Queue::song(Song::Position(SongPosition(1))).command(), RawCommand::new("playlistinfo").argument("1"));
assert_eq!(Queue::song(Song::Id(SongId(7))).command(), RawCommand::new("playlistid").argument("7"));
assert_eq!(Queue::range(SongPosition(3)..SongPosition(18)).command(), RawCommand::new("playlistinfo").argument("3:18"));
assert_eq!(
Queue::song(Song::Position(SongPosition(1))).command(),
RawCommand::new("playlistinfo").argument("1")
);
assert_eq!(
Queue::song(Song::Id(SongId(7))).command(),
RawCommand::new("playlistid").argument("7")
);
assert_eq!(
Queue::range(SongPosition(3)..SongPosition(18)).command(),
RawCommand::new("playlistinfo").argument("3:18")
);
}

#[test]
Expand Down Expand Up @@ -1839,7 +1849,10 @@ mod tests {
#[test]
fn command_shuffle() {
assert_eq!(Shuffle::all().command(), RawCommand::new("shuffle"));
assert_eq!(Shuffle::range(SongPosition(0)..SongPosition(2)).command(), RawCommand::new("shuffle").argument("0:2"));
assert_eq!(
Shuffle::range(SongPosition(0)..SongPosition(2)).command(),
RawCommand::new("shuffle").argument("0:2")
);
}

#[test]
Expand Down

0 comments on commit 33b4a72

Please sign in to comment.