diff --git a/src/commands/mounts_and_neighbors/mount.rs b/src/commands/mounts_and_neighbors/mount.rs index 2dcb77d0..9df1f21e 100644 --- a/src/commands/mounts_and_neighbors/mount.rs +++ b/src/commands/mounts_and_neighbors/mount.rs @@ -25,10 +25,10 @@ impl Command for Mount { } fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { - let path = parts - .next() - .ok_or(RequestParserError::UnexpectedEOF)? - .to_string(); + let path = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; + let path = path + .parse() + .map_err(|_| RequestParserError::SyntaxError(0, path.to_string()))?; let uri = parts .next() diff --git a/src/commands/mounts_and_neighbors/unmount.rs b/src/commands/mounts_and_neighbors/unmount.rs index aad68e08..5adaf44d 100644 --- a/src/commands/mounts_and_neighbors/unmount.rs +++ b/src/commands/mounts_and_neighbors/unmount.rs @@ -19,10 +19,10 @@ impl Command for Unmount { } fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { - let path = parts - .next() - .ok_or(RequestParserError::UnexpectedEOF)? - .to_string(); + let path = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; + let path = path + .parse() + .map_err(|_| RequestParserError::SyntaxError(0, path.to_string()))?; debug_assert!(parts.next().is_none()); diff --git a/src/common/types.rs b/src/common/types.rs index 30b4e7bd..cf5e1757 100644 --- a/src/common/types.rs +++ b/src/common/types.rs @@ -14,6 +14,8 @@ mod time_interval; mod volume_value; mod window_range; +use std::path::PathBuf; + pub use absolute_relative_song_position::AbsouluteRelativeSongPosition; pub use audio::Audio; pub use bool_or_oneshot::BoolOrOneshot; @@ -31,6 +33,7 @@ pub use volume_value::VolumeValue; pub use window_range::WindowRange; pub type AudioOutputId = u32; +pub type MountPath = PathBuf; pub type Offset = u32; pub type PlaylistName = String; pub type PlaylistVersion = u32; @@ -43,7 +46,6 @@ pub type TimeWithFractions = f64; // TODO: use a proper types pub type Feature = String; pub type PartitionName = String; -pub type Path = String; pub type StickerType = String; pub type TagName = String; pub type TagValue = String; diff --git a/src/request.rs b/src/request.rs index cb6dfc91..8b1d7949 100644 --- a/src/request.rs +++ b/src/request.rs @@ -130,8 +130,8 @@ pub enum Request { Rescan(Option), // -- Mount and Neighbor Commands -- // - Mount(Path, Uri), - Unmount(Path), + Mount(MountPath, Uri), + Unmount(MountPath), ListMounts, ListNeighbors,