commands: constructors for all commands
This commit is contained in:
@@ -15,6 +15,12 @@ empty_command_request!(Outputs, "outputs");
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct OutputsResponse(Vec<Output>);
|
||||
|
||||
impl OutputsResponse {
|
||||
pub fn new(outputs: Vec<Output>) -> Self {
|
||||
OutputsResponse(outputs)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Output {
|
||||
pub id: AudioOutputId,
|
||||
@@ -24,6 +30,24 @@ pub struct Output {
|
||||
pub attribute: HashMap<String, String>,
|
||||
}
|
||||
|
||||
impl Output {
|
||||
pub fn new(
|
||||
id: AudioOutputId,
|
||||
name: String,
|
||||
plugin: String,
|
||||
enabled: bool,
|
||||
attribute: HashMap<String, String>,
|
||||
) -> Self {
|
||||
Output {
|
||||
id,
|
||||
name,
|
||||
plugin,
|
||||
enabled,
|
||||
attribute,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for OutputsResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -15,6 +15,16 @@ pub struct OutputSetRequest {
|
||||
pub attribute_value: String,
|
||||
}
|
||||
|
||||
impl OutputSetRequest {
|
||||
pub fn new(output_id: AudioOutputId, attribute_name: String, attribute_value: String) -> Self {
|
||||
Self {
|
||||
output_id,
|
||||
attribute_name,
|
||||
attribute_value,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for OutputSetRequest {
|
||||
const COMMAND: &'static str = "outputset";
|
||||
const MIN_ARGS: u32 = 3;
|
||||
|
||||
@@ -15,6 +15,12 @@ pub struct ChannelsResponse {
|
||||
pub channels: Vec<ChannelName>,
|
||||
}
|
||||
|
||||
impl ChannelsResponse {
|
||||
pub fn new(channels: Vec<ChannelName>) -> Self {
|
||||
ChannelsResponse { channels }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for ChannelsResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -13,12 +13,24 @@ empty_command_request!(ReadMessages, "readmessages");
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ReadMessagesResponse(Vec<ReadMessagesResponseEntry>);
|
||||
|
||||
impl ReadMessagesResponse {
|
||||
pub fn new(entries: Vec<ReadMessagesResponseEntry>) -> Self {
|
||||
ReadMessagesResponse(entries)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ReadMessagesResponseEntry {
|
||||
channel: ChannelName,
|
||||
message: String,
|
||||
}
|
||||
|
||||
impl ReadMessagesResponseEntry {
|
||||
pub fn new(channel: ChannelName, message: String) -> Self {
|
||||
ReadMessagesResponseEntry { channel, message }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for ReadMessagesResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -14,6 +14,12 @@ pub struct SendMessageRequest {
|
||||
pub message: String,
|
||||
}
|
||||
|
||||
impl SendMessageRequest {
|
||||
pub fn new(channel: ChannelName, message: String) -> Self {
|
||||
Self { channel, message }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for SendMessageRequest {
|
||||
const COMMAND: &'static str = "sendmessage";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
|
||||
@@ -8,6 +8,12 @@ pub struct ProtocolDisable;
|
||||
|
||||
pub struct ProtocolDisableRequest(Vec<Feature>);
|
||||
|
||||
impl ProtocolDisableRequest {
|
||||
pub fn new(features: Vec<Feature>) -> Self {
|
||||
ProtocolDisableRequest(features)
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for ProtocolDisableRequest {
|
||||
const COMMAND: &'static str = "protocol disable";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
|
||||
@@ -8,6 +8,12 @@ pub struct ProtocolEnable;
|
||||
|
||||
pub struct ProtocolEnableRequest(Vec<Feature>);
|
||||
|
||||
impl ProtocolEnableRequest {
|
||||
pub fn new(features: Vec<Feature>) -> Self {
|
||||
ProtocolEnableRequest(features)
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for ProtocolEnableRequest {
|
||||
const COMMAND: &'static str = "protocol enable";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
|
||||
@@ -10,6 +10,12 @@ pub struct TagTypesDisable;
|
||||
|
||||
pub struct TagTypesDisableRequest(Vec<TagName>);
|
||||
|
||||
impl TagTypesDisableRequest {
|
||||
pub fn new(tag_types: Vec<TagName>) -> Self {
|
||||
TagTypesDisableRequest(tag_types)
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for TagTypesDisableRequest {
|
||||
const COMMAND: &'static str = "tagtypes disable";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
|
||||
@@ -8,6 +8,12 @@ pub struct TagTypesEnable;
|
||||
|
||||
pub struct TagTypesEnableRequest(Vec<TagName>);
|
||||
|
||||
impl TagTypesEnableRequest {
|
||||
pub fn new(tag_types: Vec<TagName>) -> Self {
|
||||
TagTypesEnableRequest(tag_types)
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for TagTypesEnableRequest {
|
||||
const COMMAND: &'static str = "tagtypes enable";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
|
||||
@@ -8,6 +8,12 @@ pub struct TagTypesReset;
|
||||
|
||||
pub struct TagTypesResetRequest(Vec<TagName>);
|
||||
|
||||
impl TagTypesResetRequest {
|
||||
pub fn new(tag_types: Vec<TagName>) -> Self {
|
||||
TagTypesResetRequest(tag_types)
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for TagTypesResetRequest {
|
||||
const COMMAND: &'static str = "tagtypes reset";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
|
||||
@@ -7,6 +7,12 @@ pub struct Pause;
|
||||
|
||||
pub struct PauseRequest(Option<bool>);
|
||||
|
||||
impl PauseRequest {
|
||||
pub fn new(state: Option<bool>) -> Self {
|
||||
PauseRequest(state)
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for PauseRequest {
|
||||
const COMMAND: &'static str = "pause";
|
||||
const MIN_ARGS: u32 = 0;
|
||||
|
||||
@@ -14,6 +14,12 @@ pub struct SeekRequest {
|
||||
pub time: TimeWithFractions,
|
||||
}
|
||||
|
||||
impl SeekRequest {
|
||||
pub fn new(songpos: SongPosition, time: TimeWithFractions) -> Self {
|
||||
Self { songpos, time }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for SeekRequest {
|
||||
const COMMAND: &'static str = "seek";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
|
||||
@@ -14,6 +14,12 @@ pub struct SeekCurRequest {
|
||||
pub time: TimeWithFractions,
|
||||
}
|
||||
|
||||
impl SeekCurRequest {
|
||||
pub fn new(mode: SeekMode, time: TimeWithFractions) -> Self {
|
||||
Self { mode, time }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for SeekCurRequest {
|
||||
const COMMAND: &'static str = "seekcur";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
|
||||
@@ -14,6 +14,12 @@ pub struct SeekIdRequest {
|
||||
pub time: TimeWithFractions,
|
||||
}
|
||||
|
||||
impl SeekIdRequest {
|
||||
pub fn new(songid: SongId, time: TimeWithFractions) -> Self {
|
||||
Self { songid, time }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for SeekIdRequest {
|
||||
const COMMAND: &'static str = "seekid";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
|
||||
@@ -14,6 +14,12 @@ empty_command_request!(ListNeighbors, "listneighbors");
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ListNeighborsResponse(HashMap<String, String>);
|
||||
|
||||
impl ListNeighborsResponse {
|
||||
pub fn new(map: HashMap<String, String>) -> Self {
|
||||
ListNeighborsResponse(map)
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for ListNeighborsResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -14,6 +14,12 @@ pub struct MountRequest {
|
||||
pub uri: Uri,
|
||||
}
|
||||
|
||||
impl MountRequest {
|
||||
pub fn new(path: MountPath, uri: Uri) -> Self {
|
||||
MountRequest { path, uri }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for MountRequest {
|
||||
const COMMAND: &'static str = "mount";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
|
||||
@@ -10,6 +10,12 @@ pub struct Unmount;
|
||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
pub struct UnmountRequest(MountPath);
|
||||
|
||||
impl UnmountRequest {
|
||||
pub fn new(path: MountPath) -> Self {
|
||||
UnmountRequest(path)
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for UnmountRequest {
|
||||
const COMMAND: &'static str = "unmount";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
|
||||
@@ -17,6 +17,12 @@ pub struct AlbumArtRequest {
|
||||
offset: Offset,
|
||||
}
|
||||
|
||||
impl AlbumArtRequest {
|
||||
pub fn new(uri: Uri, offset: Offset) -> Self {
|
||||
AlbumArtRequest { uri, offset }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for AlbumArtRequest {
|
||||
const COMMAND: &'static str = "albumart";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
@@ -69,6 +75,12 @@ pub struct AlbumArtResponse {
|
||||
pub binary: Vec<u8>,
|
||||
}
|
||||
|
||||
impl AlbumArtResponse {
|
||||
pub fn new(size: usize, binary: Vec<u8>) -> Self {
|
||||
AlbumArtResponse { size, binary }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for AlbumArtResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -18,6 +18,12 @@ pub struct CountRequest {
|
||||
group: Option<GroupType>,
|
||||
}
|
||||
|
||||
impl CountRequest {
|
||||
pub fn new(filter: Filter, group: Option<GroupType>) -> Self {
|
||||
CountRequest { filter, group }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for CountRequest {
|
||||
const COMMAND: &'static str = "count";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
@@ -84,6 +90,12 @@ pub struct CountResponse {
|
||||
pub playtime: u64,
|
||||
}
|
||||
|
||||
impl CountResponse {
|
||||
pub fn new(songs: usize, playtime: u64) -> Self {
|
||||
CountResponse { songs, playtime }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for CountResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -17,6 +17,16 @@ pub struct FindRequest {
|
||||
window: Option<WindowRange>,
|
||||
}
|
||||
|
||||
impl FindRequest {
|
||||
pub fn new(filter: Filter, sort: Option<Sort>, window: Option<WindowRange>) -> Self {
|
||||
Self {
|
||||
filter,
|
||||
sort,
|
||||
window,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for FindRequest {
|
||||
const COMMAND: &'static str = "find";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
@@ -111,6 +121,12 @@ impl CommandRequest for FindRequest {
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct FindResponse(Vec<DbSongInfo>);
|
||||
|
||||
impl FindResponse {
|
||||
pub fn new(items: Vec<DbSongInfo>) -> Self {
|
||||
FindResponse(items)
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for FindResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -17,6 +17,22 @@ pub struct FindAddRequest {
|
||||
position: Option<SongPosition>,
|
||||
}
|
||||
|
||||
impl FindAddRequest {
|
||||
pub fn new(
|
||||
filter: Filter,
|
||||
sort: Option<Sort>,
|
||||
window: Option<WindowRange>,
|
||||
position: Option<SongPosition>,
|
||||
) -> Self {
|
||||
Self {
|
||||
filter,
|
||||
sort,
|
||||
window,
|
||||
position,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for FindAddRequest {
|
||||
const COMMAND: &'static str = "findadd";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
|
||||
@@ -17,6 +17,12 @@ pub struct GetFingerprintResponse {
|
||||
pub chromaprint: String,
|
||||
}
|
||||
|
||||
impl GetFingerprintResponse {
|
||||
pub fn new(chromaprint: String) -> Self {
|
||||
Self { chromaprint }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for GetFingerprintResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -18,6 +18,22 @@ pub struct ListRequest {
|
||||
window: Option<WindowRange>,
|
||||
}
|
||||
|
||||
impl ListRequest {
|
||||
pub fn new(
|
||||
tagname: TagName,
|
||||
filter: Option<Filter>,
|
||||
groups: Vec<GroupType>,
|
||||
window: Option<WindowRange>,
|
||||
) -> Self {
|
||||
Self {
|
||||
tagname,
|
||||
filter,
|
||||
groups,
|
||||
window,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for ListRequest {
|
||||
const COMMAND: &'static str = "list";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
@@ -138,6 +154,12 @@ impl CommandRequest for ListRequest {
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ListResponse(Vec<String>);
|
||||
|
||||
impl ListResponse {
|
||||
pub fn new(items: Vec<String>) -> Self {
|
||||
ListResponse(items)
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for ListResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -16,6 +16,12 @@ single_optional_item_command_request!(ListAll, "listall", Uri);
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ListAllResponse(Vec<DbSelectionPrintResponse>);
|
||||
|
||||
impl ListAllResponse {
|
||||
pub fn new(items: Vec<DbSelectionPrintResponse>) -> Self {
|
||||
ListAllResponse(items)
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for ListAllResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -16,6 +16,12 @@ single_optional_item_command_request!(ListAllInfo, "listallinfo", Uri);
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ListAllInfoResponse(Vec<DbSelectionPrintResponse>);
|
||||
|
||||
impl ListAllInfoResponse {
|
||||
pub fn new(items: Vec<DbSelectionPrintResponse>) -> Self {
|
||||
ListAllInfoResponse(items)
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for ListAllInfoResponse {
|
||||
fn from_response_enum(response: crate::Response) -> Option<Self> {
|
||||
todo!()
|
||||
|
||||
@@ -15,6 +15,12 @@ single_optional_item_command_request!(ListFiles, "listfiles", Uri);
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ListFilesResponse(Vec<DbDirectoryInfo>);
|
||||
|
||||
impl ListFilesResponse {
|
||||
pub fn new(items: Vec<DbDirectoryInfo>) -> Self {
|
||||
ListFilesResponse(items)
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for ListFilesResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -15,6 +15,12 @@ single_optional_item_command_request!(LsInfo, "lsinfo", Uri);
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct LsInfoResponse(Vec<DbSelectionPrintResponse>);
|
||||
|
||||
impl LsInfoResponse {
|
||||
pub fn new(items: Vec<DbSelectionPrintResponse>) -> Self {
|
||||
LsInfoResponse(items)
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for LsInfoResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -15,6 +15,12 @@ single_item_command_request!(ReadComments, "readcomments", Uri);
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ReadCommentsResponse(HashMap<String, String>);
|
||||
|
||||
impl ReadCommentsResponse {
|
||||
pub fn new(comments: HashMap<String, String>) -> Self {
|
||||
ReadCommentsResponse(comments)
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for ReadCommentsResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -19,6 +19,12 @@ pub struct ReadPictureRequest {
|
||||
pub offset: Offset,
|
||||
}
|
||||
|
||||
impl ReadPictureRequest {
|
||||
pub fn new(uri: Uri, offset: Offset) -> Self {
|
||||
Self { uri, offset }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for ReadPictureRequest {
|
||||
const COMMAND: &'static str = "readpicture";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
@@ -72,6 +78,16 @@ pub struct ReadPictureResponse {
|
||||
pub mimetype: Option<String>,
|
||||
}
|
||||
|
||||
impl ReadPictureResponse {
|
||||
pub fn new(size: usize, binary: Vec<u8>, mimetype: Option<String>) -> Self {
|
||||
Self {
|
||||
size,
|
||||
binary,
|
||||
mimetype,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for ReadPictureResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -19,6 +19,12 @@ pub struct RescanResponse {
|
||||
pub updating_db: usize,
|
||||
}
|
||||
|
||||
impl RescanResponse {
|
||||
pub fn new(updating_db: usize) -> Self {
|
||||
RescanResponse { updating_db }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for RescanResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -17,6 +17,16 @@ pub struct SearchRequest {
|
||||
window: Option<WindowRange>,
|
||||
}
|
||||
|
||||
impl SearchRequest {
|
||||
pub fn new(filter: Filter, sort: Option<Sort>, window: Option<WindowRange>) -> Self {
|
||||
Self {
|
||||
filter,
|
||||
sort,
|
||||
window,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for SearchRequest {
|
||||
const COMMAND: &'static str = "search";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
@@ -111,6 +121,12 @@ impl CommandRequest for SearchRequest {
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct SearchResponse(Vec<DbSongInfo>);
|
||||
|
||||
impl SearchResponse {
|
||||
pub fn new(items: Vec<DbSongInfo>) -> Self {
|
||||
SearchResponse(items)
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for SearchResponse {
|
||||
fn from_response_enum(response: crate::Response) -> Option<Self> {
|
||||
todo!()
|
||||
|
||||
@@ -17,6 +17,22 @@ pub struct SearchAddRequest {
|
||||
position: Option<SongPosition>,
|
||||
}
|
||||
|
||||
impl SearchAddRequest {
|
||||
pub fn new(
|
||||
filter: Filter,
|
||||
sort: Option<Sort>,
|
||||
window: Option<WindowRange>,
|
||||
position: Option<SongPosition>,
|
||||
) -> Self {
|
||||
Self {
|
||||
filter,
|
||||
sort,
|
||||
window,
|
||||
position,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for SearchAddRequest {
|
||||
const COMMAND: &'static str = "searchadd";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
|
||||
@@ -18,6 +18,24 @@ pub struct SearchAddPlRequest {
|
||||
position: Option<SongPosition>,
|
||||
}
|
||||
|
||||
impl SearchAddPlRequest {
|
||||
pub fn new(
|
||||
playlist_name: PlaylistName,
|
||||
filter: Filter,
|
||||
sort: Option<Sort>,
|
||||
window: Option<WindowRange>,
|
||||
position: Option<SongPosition>,
|
||||
) -> Self {
|
||||
Self {
|
||||
playlist_name,
|
||||
filter,
|
||||
sort,
|
||||
window,
|
||||
position,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for SearchAddPlRequest {
|
||||
const COMMAND: &'static str = "searchaddpl";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
|
||||
@@ -18,6 +18,12 @@ pub struct SearchCountRequest {
|
||||
group: Option<GroupType>,
|
||||
}
|
||||
|
||||
impl SearchCountRequest {
|
||||
pub fn new(filter: Filter, group: Option<GroupType>) -> Self {
|
||||
Self { filter, group }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for SearchCountRequest {
|
||||
const COMMAND: &'static str = "searchcount";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
@@ -85,6 +91,12 @@ pub struct SearchCountResponse {
|
||||
pub playtime: Seconds,
|
||||
}
|
||||
|
||||
impl SearchCountResponse {
|
||||
pub fn new(songs: usize, playtime: Seconds) -> Self {
|
||||
Self { songs, playtime }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for SearchCountResponse {
|
||||
fn from_response_enum(response: crate::Response) -> Option<Self> {
|
||||
todo!()
|
||||
|
||||
@@ -19,6 +19,12 @@ pub struct UpdateResponse {
|
||||
updating_db: usize,
|
||||
}
|
||||
|
||||
impl UpdateResponse {
|
||||
pub fn new(updating_db: usize) -> Self {
|
||||
UpdateResponse { updating_db }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for UpdateResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -6,6 +6,7 @@ use crate::{
|
||||
pub struct MixRampDelay;
|
||||
|
||||
single_item_command_request!(MixRampDelay, "mixrampdelay", Seconds);
|
||||
|
||||
empty_command_response!(MixRampDelay);
|
||||
|
||||
impl Command for MixRampDelay {
|
||||
|
||||
@@ -7,6 +7,12 @@ pub struct Random;
|
||||
|
||||
pub struct RandomRequest(bool);
|
||||
|
||||
impl RandomRequest {
|
||||
pub fn new(state: bool) -> Self {
|
||||
Self(state)
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for RandomRequest {
|
||||
const COMMAND: &'static str = "random";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
|
||||
@@ -7,6 +7,12 @@ pub struct Repeat;
|
||||
|
||||
pub struct RepeatRequest(bool);
|
||||
|
||||
impl RepeatRequest {
|
||||
pub fn new(state: bool) -> Self {
|
||||
RepeatRequest(state)
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for RepeatRequest {
|
||||
const COMMAND: &'static str = "repeat";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
|
||||
@@ -17,6 +17,12 @@ pub struct ReplayGainStatusResponse {
|
||||
pub replay_gain_mode: ReplayGainModeMode,
|
||||
}
|
||||
|
||||
impl ReplayGainStatusResponse {
|
||||
pub fn new(replay_gain_mode: ReplayGainModeMode) -> Self {
|
||||
Self { replay_gain_mode }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for ReplayGainStatusResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -23,6 +23,22 @@ pub struct CurrentSongResponse {
|
||||
song_info: DbSongInfo,
|
||||
}
|
||||
|
||||
impl CurrentSongResponse {
|
||||
pub fn new(
|
||||
position: SongPosition,
|
||||
id: SongId,
|
||||
priority: Option<Priority>,
|
||||
song_info: DbSongInfo,
|
||||
) -> Self {
|
||||
Self {
|
||||
position,
|
||||
id,
|
||||
priority,
|
||||
song_info,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for CurrentSongResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -10,6 +10,12 @@ pub struct Idle;
|
||||
|
||||
pub struct IdleRequest(Option<Vec<SubSystem>>);
|
||||
|
||||
impl IdleRequest {
|
||||
pub fn new(subsystems: Option<Vec<SubSystem>>) -> Self {
|
||||
IdleRequest(subsystems)
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for IdleRequest {
|
||||
const COMMAND: &'static str = "idle";
|
||||
const MIN_ARGS: u32 = 0;
|
||||
|
||||
@@ -24,6 +24,28 @@ pub struct StatsResponse {
|
||||
pub db_update: Option<u64>,
|
||||
}
|
||||
|
||||
impl StatsResponse {
|
||||
pub fn new(
|
||||
uptime: u64,
|
||||
playtime: u64,
|
||||
artists: Option<u64>,
|
||||
albums: Option<u64>,
|
||||
songs: Option<u64>,
|
||||
db_playtime: Option<u64>,
|
||||
db_update: Option<u64>,
|
||||
) -> Self {
|
||||
Self {
|
||||
uptime,
|
||||
playtime,
|
||||
artists,
|
||||
albums,
|
||||
songs,
|
||||
db_playtime,
|
||||
db_update,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for StatsResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -65,6 +65,62 @@ pub struct StatusResponse {
|
||||
pub last_loaded_playlist: Option<String>,
|
||||
}
|
||||
|
||||
impl StatusResponse {
|
||||
pub fn new(
|
||||
partition: String,
|
||||
volume: Option<u8>,
|
||||
repeat: bool,
|
||||
random: bool,
|
||||
single: BoolOrOneshot,
|
||||
consume: BoolOrOneshot,
|
||||
playlist: u32,
|
||||
playlist_length: u64,
|
||||
state: StatusResponseState,
|
||||
song: Option<SongPosition>,
|
||||
song_id: Option<SongId>,
|
||||
next_song: Option<SongPosition>,
|
||||
next_song_id: Option<SongId>,
|
||||
time: Option<(u64, u64)>,
|
||||
elapsed: Option<f64>,
|
||||
duration: Option<f64>,
|
||||
bitrate: Option<u32>,
|
||||
xfade: Option<u32>,
|
||||
mixrampdb: Option<f64>,
|
||||
mixrampdelay: Option<f64>,
|
||||
audio: Option<Audio>,
|
||||
updating_db: Option<u64>,
|
||||
error: Option<String>,
|
||||
last_loaded_playlist: Option<String>,
|
||||
) -> Self {
|
||||
Self {
|
||||
partition,
|
||||
volume,
|
||||
repeat,
|
||||
random,
|
||||
single,
|
||||
consume,
|
||||
playlist,
|
||||
playlist_length,
|
||||
state,
|
||||
song,
|
||||
song_id,
|
||||
next_song,
|
||||
next_song_id,
|
||||
time,
|
||||
elapsed,
|
||||
duration,
|
||||
bitrate,
|
||||
xfade,
|
||||
mixrampdb,
|
||||
mixrampdelay,
|
||||
audio,
|
||||
updating_db,
|
||||
error,
|
||||
last_loaded_playlist,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for StatusResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -14,6 +14,12 @@ pub struct AddRequest {
|
||||
position: Option<SongPosition>,
|
||||
}
|
||||
|
||||
impl AddRequest {
|
||||
pub fn new(uri: Uri, position: Option<SongPosition>) -> Self {
|
||||
Self { uri, position }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for AddRequest {
|
||||
const COMMAND: &'static str = "add";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
|
||||
@@ -15,6 +15,12 @@ pub struct AddIdRequest {
|
||||
pub position: Option<SongPosition>,
|
||||
}
|
||||
|
||||
impl AddIdRequest {
|
||||
pub fn new(uri: Uri, position: Option<SongPosition>) -> Self {
|
||||
Self { uri, position }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for AddIdRequest {
|
||||
const COMMAND: &'static str = "addid";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
@@ -69,6 +75,12 @@ pub struct AddIdResponse {
|
||||
pub id: SongId,
|
||||
}
|
||||
|
||||
impl AddIdResponse {
|
||||
pub fn new(id: SongId) -> Self {
|
||||
Self { id }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for AddIdResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -15,6 +15,16 @@ pub struct AddTagIdRequest {
|
||||
pub tag_value: TagValue,
|
||||
}
|
||||
|
||||
impl AddTagIdRequest {
|
||||
pub fn new(songid: SongId, tag_name: TagName, tag_value: TagValue) -> Self {
|
||||
Self {
|
||||
songid,
|
||||
tag_name,
|
||||
tag_value,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for AddTagIdRequest {
|
||||
const COMMAND: &'static str = "addtagid";
|
||||
const MIN_ARGS: u32 = 3;
|
||||
|
||||
@@ -14,6 +14,12 @@ pub struct ClearTagIdRequest {
|
||||
pub tag_name: TagName,
|
||||
}
|
||||
|
||||
impl ClearTagIdRequest {
|
||||
pub fn new(songid: SongId, tag_name: TagName) -> Self {
|
||||
Self { songid, tag_name }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for ClearTagIdRequest {
|
||||
const COMMAND: &'static str = "cleartagid";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
|
||||
@@ -14,6 +14,12 @@ pub struct MoveRequest {
|
||||
pub to: AbsouluteRelativeSongPosition,
|
||||
}
|
||||
|
||||
impl MoveRequest {
|
||||
pub fn new(from_or_range: OneOrRange, to: AbsouluteRelativeSongPosition) -> Self {
|
||||
Self { from_or_range, to }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for MoveRequest {
|
||||
const COMMAND: &'static str = "move";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
|
||||
@@ -14,6 +14,12 @@ pub struct MoveIdRequest {
|
||||
pub to: AbsouluteRelativeSongPosition,
|
||||
}
|
||||
|
||||
impl MoveIdRequest {
|
||||
pub fn new(id: SongId, to: AbsouluteRelativeSongPosition) -> Self {
|
||||
Self { id, to }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for MoveIdRequest {
|
||||
const COMMAND: &'static str = "moveid";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
|
||||
@@ -13,6 +13,12 @@ empty_command_request!(Playlist, "playlist");
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlaylistResponse(Vec<Uri>);
|
||||
|
||||
impl PlaylistResponse {
|
||||
pub fn new(items: Vec<Uri>) -> Self {
|
||||
PlaylistResponse(items)
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for PlaylistResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -18,6 +18,16 @@ pub struct PlaylistFindRequest {
|
||||
window: Option<WindowRange>,
|
||||
}
|
||||
|
||||
impl PlaylistFindRequest {
|
||||
pub fn new(filter: Filter, sort: Option<Sort>, window: Option<WindowRange>) -> Self {
|
||||
Self {
|
||||
filter,
|
||||
sort,
|
||||
window,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for PlaylistFindRequest {
|
||||
const COMMAND: &'static str = "playlistfind";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
@@ -112,6 +122,12 @@ impl CommandRequest for PlaylistFindRequest {
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlaylistFindResponse(Vec<PlaylistFindResponseEntry>);
|
||||
|
||||
impl PlaylistFindResponse {
|
||||
pub fn new(items: Vec<PlaylistFindResponseEntry>) -> Self {
|
||||
PlaylistFindResponse(items)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlaylistFindResponseEntry {
|
||||
pub position: SongPosition,
|
||||
@@ -120,6 +136,22 @@ pub struct PlaylistFindResponseEntry {
|
||||
pub song_info: DbSongInfo,
|
||||
}
|
||||
|
||||
impl PlaylistFindResponseEntry {
|
||||
pub fn new(
|
||||
position: SongPosition,
|
||||
id: SongId,
|
||||
priority: Option<Priority>,
|
||||
song_info: DbSongInfo,
|
||||
) -> Self {
|
||||
Self {
|
||||
position,
|
||||
id,
|
||||
priority,
|
||||
song_info,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for PlaylistFindResponse {
|
||||
fn into_response_enum(self) -> Response {
|
||||
todo!()
|
||||
|
||||
@@ -13,6 +13,12 @@ single_item_command_request!(PlaylistId, "playlistid", SongId);
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlaylistIdResponse(Vec<PlaylistIdResponseEntry>);
|
||||
|
||||
impl PlaylistIdResponse {
|
||||
pub fn new(items: Vec<PlaylistIdResponseEntry>) -> Self {
|
||||
PlaylistIdResponse(items)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlaylistIdResponseEntry {
|
||||
pub position: SongPosition,
|
||||
@@ -21,6 +27,22 @@ pub struct PlaylistIdResponseEntry {
|
||||
pub song_info: DbSongInfo,
|
||||
}
|
||||
|
||||
impl PlaylistIdResponseEntry {
|
||||
pub fn new(
|
||||
position: SongPosition,
|
||||
id: SongId,
|
||||
priority: Option<Priority>,
|
||||
song_info: DbSongInfo,
|
||||
) -> Self {
|
||||
PlaylistIdResponseEntry {
|
||||
position,
|
||||
id,
|
||||
priority,
|
||||
song_info,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for PlaylistIdResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -15,6 +15,12 @@ single_optional_item_command_request!(PlaylistInfo, "playlistinfo", OneOrRange);
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlaylistInfoResponse(Vec<PlaylistInfoResponseEntry>);
|
||||
|
||||
impl PlaylistInfoResponse {
|
||||
pub fn new(items: Vec<PlaylistInfoResponseEntry>) -> Self {
|
||||
PlaylistInfoResponse(items)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlaylistInfoResponseEntry {
|
||||
pub position: SongPosition,
|
||||
@@ -23,6 +29,22 @@ pub struct PlaylistInfoResponseEntry {
|
||||
pub song_info: DbSongInfo,
|
||||
}
|
||||
|
||||
impl PlaylistInfoResponseEntry {
|
||||
pub fn new(
|
||||
position: SongPosition,
|
||||
id: SongId,
|
||||
priority: Option<Priority>,
|
||||
song_info: DbSongInfo,
|
||||
) -> Self {
|
||||
PlaylistInfoResponseEntry {
|
||||
position,
|
||||
id,
|
||||
priority,
|
||||
song_info,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for PlaylistInfoResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -17,6 +17,16 @@ pub struct PlaylistSearchRequest {
|
||||
window: Option<WindowRange>,
|
||||
}
|
||||
|
||||
impl PlaylistSearchRequest {
|
||||
pub fn new(filter: Filter, sort: Option<Sort>, window: Option<WindowRange>) -> Self {
|
||||
Self {
|
||||
filter,
|
||||
sort,
|
||||
window,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for PlaylistSearchRequest {
|
||||
const COMMAND: &'static str = "playlistsearch";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
@@ -111,6 +121,12 @@ impl CommandRequest for PlaylistSearchRequest {
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlaylistSearchResponse(Vec<PlaylistSearchResponseEntry>);
|
||||
|
||||
impl PlaylistSearchResponse {
|
||||
pub fn new(items: Vec<PlaylistSearchResponseEntry>) -> Self {
|
||||
PlaylistSearchResponse(items)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlaylistSearchResponseEntry {
|
||||
pub position: SongPosition,
|
||||
@@ -119,6 +135,22 @@ pub struct PlaylistSearchResponseEntry {
|
||||
pub song_info: DbSongInfo,
|
||||
}
|
||||
|
||||
impl PlaylistSearchResponseEntry {
|
||||
pub fn new(
|
||||
position: SongPosition,
|
||||
id: SongId,
|
||||
priority: Option<Priority>,
|
||||
song_info: DbSongInfo,
|
||||
) -> Self {
|
||||
Self {
|
||||
position,
|
||||
id,
|
||||
priority,
|
||||
song_info,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for PlaylistSearchResponse {
|
||||
fn from_response_enum(response: crate::Response) -> Option<Self> {
|
||||
todo!()
|
||||
|
||||
@@ -15,6 +15,12 @@ pub struct PlChangesRequest {
|
||||
pub window: Option<WindowRange>,
|
||||
}
|
||||
|
||||
impl PlChangesRequest {
|
||||
pub fn new(version: PlaylistVersion, window: Option<WindowRange>) -> Self {
|
||||
Self { version, window }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for PlChangesRequest {
|
||||
const COMMAND: &'static str = "plchanges";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
@@ -71,6 +77,12 @@ impl CommandRequest for PlChangesRequest {
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlChangesResponse(Vec<PlChangesResponseEntry>);
|
||||
|
||||
impl PlChangesResponse {
|
||||
pub fn new(items: Vec<PlChangesResponseEntry>) -> Self {
|
||||
PlChangesResponse(items)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlChangesResponseEntry {
|
||||
pub position: SongPosition,
|
||||
@@ -79,6 +91,22 @@ pub struct PlChangesResponseEntry {
|
||||
pub song_info: DbSongInfo,
|
||||
}
|
||||
|
||||
impl PlChangesResponseEntry {
|
||||
pub fn new(
|
||||
position: SongPosition,
|
||||
id: SongId,
|
||||
priority: Option<Priority>,
|
||||
song_info: DbSongInfo,
|
||||
) -> Self {
|
||||
PlChangesResponseEntry {
|
||||
position,
|
||||
id,
|
||||
priority,
|
||||
song_info,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for PlChangesResponse {
|
||||
fn from_response_enum(response: crate::Response) -> Option<Self> {
|
||||
todo!()
|
||||
|
||||
@@ -15,6 +15,12 @@ pub struct PlChangesPosIdRequest {
|
||||
pub window: Option<WindowRange>,
|
||||
}
|
||||
|
||||
impl PlChangesPosIdRequest {
|
||||
pub fn new(version: PlaylistVersion, window: Option<WindowRange>) -> Self {
|
||||
Self { version, window }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for PlChangesPosIdRequest {
|
||||
const COMMAND: &'static str = "plchangesposid";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
@@ -71,6 +77,12 @@ impl CommandRequest for PlChangesPosIdRequest {
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlChangesPosIdResponse(Vec<PlChangesPosIdResponseEntry>);
|
||||
|
||||
impl PlChangesPosIdResponse {
|
||||
pub fn new(items: Vec<PlChangesPosIdResponseEntry>) -> Self {
|
||||
PlChangesPosIdResponse(items)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlChangesPosIdResponseEntry {
|
||||
// 'cpos'
|
||||
@@ -78,6 +90,12 @@ pub struct PlChangesPosIdResponseEntry {
|
||||
pub id: SongId,
|
||||
}
|
||||
|
||||
impl PlChangesPosIdResponseEntry {
|
||||
pub fn new(position: SongPosition, id: SongId) -> Self {
|
||||
PlChangesPosIdResponseEntry { position, id }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for PlChangesPosIdResponse {
|
||||
fn from_response_enum(response: crate::Response) -> Option<Self> {
|
||||
todo!()
|
||||
|
||||
@@ -14,6 +14,12 @@ pub struct PrioRequest {
|
||||
pub window: WindowRange,
|
||||
}
|
||||
|
||||
impl PrioRequest {
|
||||
pub fn new(prio: Priority, window: WindowRange) -> Self {
|
||||
Self { prio, window }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for PrioRequest {
|
||||
const COMMAND: &'static str = "prio";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
|
||||
@@ -14,6 +14,12 @@ pub struct PrioIdRequest {
|
||||
pub songids: Vec<SongId>,
|
||||
}
|
||||
|
||||
impl PrioIdRequest {
|
||||
pub fn new(prio: Priority, songids: Vec<SongId>) -> Self {
|
||||
Self { prio, songids }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for PrioIdRequest {
|
||||
const COMMAND: &'static str = "prioid";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
|
||||
@@ -14,6 +14,15 @@ pub struct RangeIdRequest {
|
||||
time_interval: TimeInterval,
|
||||
}
|
||||
|
||||
impl RangeIdRequest {
|
||||
pub fn new(songid: SongId, time_interval: TimeInterval) -> Self {
|
||||
Self {
|
||||
songid,
|
||||
time_interval,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for RangeIdRequest {
|
||||
const COMMAND: &'static str = "rangeid";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
|
||||
@@ -14,6 +14,12 @@ pub struct SwapRequest {
|
||||
pub songpos2: SongPosition,
|
||||
}
|
||||
|
||||
impl SwapRequest {
|
||||
pub fn new(songpos1: SongPosition, songpos2: SongPosition) -> Self {
|
||||
Self { songpos1, songpos2 }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for SwapRequest {
|
||||
const COMMAND: &'static str = "swap";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
|
||||
@@ -14,6 +14,12 @@ pub struct SwapIdRequest {
|
||||
pub songid2: SongId,
|
||||
}
|
||||
|
||||
impl SwapIdRequest {
|
||||
pub fn new(songid1: SongId, songid2: SongId) -> Self {
|
||||
Self { songid1, songid2 }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for SwapIdRequest {
|
||||
const COMMAND: &'static str = "swapid";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
|
||||
@@ -18,6 +18,16 @@ pub struct ConfigResponse {
|
||||
pub pcre: bool,
|
||||
}
|
||||
|
||||
impl ConfigResponse {
|
||||
pub fn new(music_directory: String, playlist_directory: String, pcre: bool) -> Self {
|
||||
ConfigResponse {
|
||||
music_directory,
|
||||
playlist_directory,
|
||||
pcre,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for ConfigResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -16,9 +16,25 @@ pub struct Decoder {
|
||||
pub mime_types: Vec<String>,
|
||||
}
|
||||
|
||||
impl Decoder {
|
||||
pub fn new(plugin: String, suffixes: Vec<String>, mime_types: Vec<String>) -> Self {
|
||||
Decoder {
|
||||
plugin,
|
||||
suffixes,
|
||||
mime_types,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct DecodersResponse(Vec<Decoder>);
|
||||
|
||||
impl DecodersResponse {
|
||||
pub fn new(items: Vec<Decoder>) -> Self {
|
||||
DecodersResponse(items)
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for DecodersResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -16,6 +16,17 @@ pub struct StickerDecRequest {
|
||||
pub value: usize,
|
||||
}
|
||||
|
||||
impl StickerDecRequest {
|
||||
pub fn new(sticker_type: StickerType, uri: Uri, name: String, value: usize) -> Self {
|
||||
Self {
|
||||
sticker_type,
|
||||
uri,
|
||||
name,
|
||||
value,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for StickerDecRequest {
|
||||
const COMMAND: &'static str = "sticker dec";
|
||||
const MIN_ARGS: u32 = 4;
|
||||
|
||||
@@ -15,6 +15,16 @@ pub struct StickerDeleteRequest {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
impl StickerDeleteRequest {
|
||||
pub fn new(sticker_type: StickerType, uri: Uri, name: String) -> Self {
|
||||
Self {
|
||||
sticker_type,
|
||||
uri,
|
||||
name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for StickerDeleteRequest {
|
||||
const COMMAND: &'static str = "sticker delete";
|
||||
const MIN_ARGS: u32 = 3;
|
||||
|
||||
@@ -18,6 +18,24 @@ pub struct StickerFindRequest {
|
||||
pub window: Option<WindowRange>,
|
||||
}
|
||||
|
||||
impl StickerFindRequest {
|
||||
pub fn new(
|
||||
sticker_type: StickerType,
|
||||
uri: Uri,
|
||||
name: String,
|
||||
sort: Option<Sort>,
|
||||
window: Option<WindowRange>,
|
||||
) -> Self {
|
||||
Self {
|
||||
sticker_type,
|
||||
uri,
|
||||
name,
|
||||
sort,
|
||||
window,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for StickerFindRequest {
|
||||
const COMMAND: &'static str = "sticker find";
|
||||
const MIN_ARGS: u32 = 3;
|
||||
@@ -151,6 +169,12 @@ impl CommandRequest for StickerFindRequest {
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct StickerFindResponse(Vec<StickerFindResponseEntry>);
|
||||
|
||||
impl StickerFindResponse {
|
||||
pub fn new(items: Vec<StickerFindResponseEntry>) -> Self {
|
||||
StickerFindResponse(items)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct StickerFindResponseEntry {
|
||||
pub uri: String,
|
||||
@@ -158,6 +182,12 @@ pub struct StickerFindResponseEntry {
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
impl StickerFindResponseEntry {
|
||||
pub fn new(uri: String, name: String, value: String) -> Self {
|
||||
Self { uri, name, value }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for StickerFindResponse {
|
||||
fn from_response_enum(response: crate::Response) -> Option<Self> {
|
||||
todo!()
|
||||
|
||||
@@ -15,6 +15,16 @@ pub struct StickerGetRequest {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
impl StickerGetRequest {
|
||||
pub fn new(sticker_type: StickerType, uri: Uri, name: String) -> Self {
|
||||
Self {
|
||||
sticker_type,
|
||||
uri,
|
||||
name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for StickerGetRequest {
|
||||
const COMMAND: &'static str = "sticker get";
|
||||
const MIN_ARGS: u32 = 3;
|
||||
|
||||
@@ -16,6 +16,17 @@ pub struct StickerIncRequest {
|
||||
pub value: usize,
|
||||
}
|
||||
|
||||
impl StickerIncRequest {
|
||||
pub fn new(sticker_type: StickerType, uri: Uri, name: String, value: usize) -> Self {
|
||||
Self {
|
||||
sticker_type,
|
||||
uri,
|
||||
name,
|
||||
value,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for StickerIncRequest {
|
||||
const COMMAND: &'static str = "sticker inc";
|
||||
const MIN_ARGS: u32 = 4;
|
||||
|
||||
@@ -17,6 +17,12 @@ pub struct StickerListRequest {
|
||||
pub uri: Uri,
|
||||
}
|
||||
|
||||
impl StickerListRequest {
|
||||
pub fn new(sticker_type: StickerType, uri: Uri) -> Self {
|
||||
Self { sticker_type, uri }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for StickerListRequest {
|
||||
const COMMAND: &'static str = "sticker list";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
@@ -68,6 +74,12 @@ impl CommandRequest for StickerListRequest {
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct StickerListResponse(HashMap<String, String>);
|
||||
|
||||
impl StickerListResponse {
|
||||
pub fn new(map: HashMap<String, String>) -> Self {
|
||||
StickerListResponse(map)
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for StickerListResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -16,6 +16,17 @@ pub struct StickerSetRequest {
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
impl StickerSetRequest {
|
||||
pub fn new(sticker_type: StickerType, uri: Uri, name: String, value: String) -> Self {
|
||||
Self {
|
||||
sticker_type,
|
||||
uri,
|
||||
name,
|
||||
value,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for StickerSetRequest {
|
||||
const COMMAND: &'static str = "sticker set";
|
||||
const MIN_ARGS: u32 = 4;
|
||||
|
||||
@@ -14,6 +14,12 @@ pub struct StickerNamesTypes;
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct StickerNamesTypesRequest(Option<StickerType>);
|
||||
|
||||
impl StickerNamesTypesRequest {
|
||||
pub fn new(sticker_type: Option<StickerType>) -> Self {
|
||||
Self(sticker_type)
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for StickerNamesTypesRequest {
|
||||
const COMMAND: &'static str = "stickernamestypes";
|
||||
const MIN_ARGS: u32 = 0;
|
||||
@@ -59,6 +65,12 @@ impl CommandRequest for StickerNamesTypesRequest {
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct StickerNamesTypesResponse(HashMap<String, Vec<String>>);
|
||||
|
||||
impl StickerNamesTypesResponse {
|
||||
pub fn new(map: HashMap<String, Vec<String>>) -> Self {
|
||||
StickerNamesTypesResponse(map)
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for StickerNamesTypesResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -20,6 +20,12 @@ pub struct ListPlaylistRequest {
|
||||
range: Option<WindowRange>,
|
||||
}
|
||||
|
||||
impl ListPlaylistRequest {
|
||||
pub fn new(name: PlaylistName, range: Option<WindowRange>) -> Self {
|
||||
Self { name, range }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for ListPlaylistRequest {
|
||||
const COMMAND: &'static str = "listplaylist";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
|
||||
@@ -15,6 +15,12 @@ pub struct ListPlaylistInfoRequest {
|
||||
range: Option<WindowRange>,
|
||||
}
|
||||
|
||||
impl ListPlaylistInfoRequest {
|
||||
pub fn new(name: PlaylistName, range: Option<WindowRange>) -> Self {
|
||||
Self { name, range }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for ListPlaylistInfoRequest {
|
||||
const COMMAND: &'static str = "listplaylistinfo";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
@@ -63,6 +69,12 @@ impl CommandRequest for ListPlaylistInfoRequest {
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ListPlaylistInfoResponse(Vec<DbSongInfo>);
|
||||
|
||||
impl ListPlaylistInfoResponse {
|
||||
pub fn new(items: Vec<DbSongInfo>) -> Self {
|
||||
ListPlaylistInfoResponse(items)
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for ListPlaylistInfoResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -13,6 +13,12 @@ empty_command_request!(ListPlaylists, "listplaylists");
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ListPlaylistsResponse(Vec<ListPlaylistsResponseEntry>);
|
||||
|
||||
impl ListPlaylistsResponse {
|
||||
pub fn new(items: Vec<ListPlaylistsResponseEntry>) -> Self {
|
||||
ListPlaylistsResponse(items)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ListPlaylistsResponseEntry {
|
||||
pub playlist: PlaylistName,
|
||||
@@ -20,6 +26,15 @@ pub struct ListPlaylistsResponseEntry {
|
||||
pub last_modified: Option<String>,
|
||||
}
|
||||
|
||||
impl ListPlaylistsResponseEntry {
|
||||
pub fn new(playlist: PlaylistName, last_modified: Option<String>) -> Self {
|
||||
ListPlaylistsResponseEntry {
|
||||
playlist,
|
||||
last_modified,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for ListPlaylistsResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -15,6 +15,20 @@ pub struct LoadRequest {
|
||||
position: Option<SongPosition>,
|
||||
}
|
||||
|
||||
impl LoadRequest {
|
||||
pub fn new(
|
||||
name: PlaylistName,
|
||||
range: Option<WindowRange>,
|
||||
position: Option<SongPosition>,
|
||||
) -> Self {
|
||||
Self {
|
||||
name,
|
||||
range,
|
||||
position,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for LoadRequest {
|
||||
const COMMAND: &'static str = "load";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
|
||||
@@ -15,6 +15,16 @@ pub struct PlaylistAddRequest {
|
||||
pub position: Option<SongPosition>,
|
||||
}
|
||||
|
||||
impl PlaylistAddRequest {
|
||||
pub fn new(playlist_name: PlaylistName, uri: Uri, position: Option<SongPosition>) -> Self {
|
||||
Self {
|
||||
playlist_name,
|
||||
uri,
|
||||
position,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for PlaylistAddRequest {
|
||||
const COMMAND: &'static str = "playlistadd";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
|
||||
@@ -14,6 +14,15 @@ pub struct PlaylistDeleteRequest {
|
||||
pub position: OneOrRange,
|
||||
}
|
||||
|
||||
impl PlaylistDeleteRequest {
|
||||
pub fn new(playlist_name: PlaylistName, position: OneOrRange) -> Self {
|
||||
Self {
|
||||
playlist_name,
|
||||
position,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for PlaylistDeleteRequest {
|
||||
const COMMAND: &'static str = "playlistdelete";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
|
||||
@@ -18,6 +18,12 @@ pub struct PlaylistLengthResponse {
|
||||
pub playtime: u64,
|
||||
}
|
||||
|
||||
impl PlaylistLengthResponse {
|
||||
pub fn new(songs: u64, playtime: u64) -> Self {
|
||||
PlaylistLengthResponse { songs, playtime }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandResponse for PlaylistLengthResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
todo!()
|
||||
|
||||
@@ -15,6 +15,16 @@ pub struct PlaylistMoveRequest {
|
||||
pub to: SongPosition,
|
||||
}
|
||||
|
||||
impl PlaylistMoveRequest {
|
||||
pub fn new(playlist_name: PlaylistName, from: Option<OneOrRange>, to: SongPosition) -> Self {
|
||||
Self {
|
||||
playlist_name,
|
||||
from,
|
||||
to,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for PlaylistMoveRequest {
|
||||
const COMMAND: &'static str = "playlistmove";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
|
||||
@@ -13,6 +13,12 @@ pub struct RenameRequest {
|
||||
pub new_name: String,
|
||||
}
|
||||
|
||||
impl RenameRequest {
|
||||
pub fn new(old_name: String, new_name: String) -> Self {
|
||||
Self { old_name, new_name }
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for RenameRequest {
|
||||
const COMMAND: &'static str = "rename";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
|
||||
@@ -14,6 +14,15 @@ pub struct SaveRequest {
|
||||
pub mode: Option<SaveMode>,
|
||||
}
|
||||
|
||||
impl SaveRequest {
|
||||
pub fn new(playlist_name: PlaylistName, mode: Option<SaveMode>) -> Self {
|
||||
Self {
|
||||
playlist_name,
|
||||
mode,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for SaveRequest {
|
||||
const COMMAND: &'static str = "save";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
|
||||
@@ -16,6 +16,16 @@ pub struct SearchPlaylistRequest {
|
||||
pub range: Option<WindowRange>,
|
||||
}
|
||||
|
||||
impl SearchPlaylistRequest {
|
||||
pub fn new(name: PlaylistName, filter: Filter, range: Option<WindowRange>) -> Self {
|
||||
Self {
|
||||
name,
|
||||
filter,
|
||||
range,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandRequest for SearchPlaylistRequest {
|
||||
const COMMAND: &'static str = "searchplaylist";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
|
||||
Reference in New Issue
Block a user