From 6d2575b94048fadc45031325013c4c4454ebaea3 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Tue, 16 Apr 2024 20:54:17 +0200 Subject: [PATCH] Add `Clone` and `Copy` to several public structs --- src/ipc.rs | 2 +- src/lib.rs | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/ipc.rs b/src/ipc.rs index 564e556..046f6c5 100644 --- a/src/ipc.rs +++ b/src/ipc.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::BufReader; use std::iter::Iterator; -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct PlaylistEntry { pub id: usize, pub filename: String, diff --git a/src/lib.rs b/src/lib.rs index f4f8857..096e72b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,7 +7,7 @@ use std::fmt::{self, Display}; use std::io::{BufReader, Read}; use std::os::unix::net::UnixStream; -#[derive(Debug)] +#[derive(Debug, Clone)] pub enum Event { Shutdown, StartFile, @@ -30,7 +30,7 @@ pub enum Event { Unimplemented, } -#[derive(Debug)] +#[derive(Debug, Clone)] pub enum Property { Path(Option), Pause(bool), @@ -40,6 +40,7 @@ pub enum Property { Unknown { name: String, data: MpvDataType }, } +#[derive(Debug, Clone)] pub enum MpvCommand { LoadFile { file: String, @@ -76,7 +77,7 @@ pub enum MpvCommand { Unobserve(isize), } -#[derive(Debug)] +#[derive(Debug, Clone)] pub enum MpvDataType { Array(Vec), Bool(bool), @@ -88,22 +89,26 @@ pub enum MpvDataType { Usize(usize), } +#[derive(Debug, Clone)] pub enum NumberChangeOptions { Absolute, Increase, Decrease, } +#[derive(Debug, Clone, Copy)] pub enum PlaylistAddOptions { Replace, Append, } +#[derive(Debug, Clone, Copy)] pub enum PlaylistAddTypeOptions { File, Playlist, } +#[derive(Debug, Clone, Copy)] pub enum SeekOptions { Relative, Absolute, @@ -111,13 +116,14 @@ pub enum SeekOptions { AbsolutePercent, } +#[derive(Debug, Clone, Copy)] pub enum Switch { On, Off, Toggle, } -#[derive(Debug)] +#[derive(Debug, Clone)] pub enum ErrorCode { MpvError(String), JsonParseError(String), @@ -140,9 +146,9 @@ pub struct Mpv { reader: BufReader, name: String, } -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct Playlist(pub Vec); -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct Error(pub ErrorCode); impl Drop for Mpv { @@ -363,8 +369,7 @@ impl Mpv { /// Ok(()) /// } /// ``` - pub fn get_property(&self, property: &str) -> Result { - T::get_property_generic(self, property) + pub fn get_property(&self, property: &str) -> Result { T::get_property_generic(self, property) } /// # Description