Add `Clone` and `Copy` to several public structs

This commit is contained in:
Oystein Kristoffer Tveit 2024-04-16 20:54:17 +02:00
parent d973f1e23e
commit 6d2575b940
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
2 changed files with 14 additions and 9 deletions

View File

@ -6,7 +6,7 @@ use std::io::prelude::*;
use std::io::BufReader; use std::io::BufReader;
use std::iter::Iterator; use std::iter::Iterator;
#[derive(Debug)] #[derive(Debug, Clone)]
pub struct PlaylistEntry { pub struct PlaylistEntry {
pub id: usize, pub id: usize,
pub filename: String, pub filename: String,

View File

@ -7,7 +7,7 @@ use std::fmt::{self, Display};
use std::io::{BufReader, Read}; use std::io::{BufReader, Read};
use std::os::unix::net::UnixStream; use std::os::unix::net::UnixStream;
#[derive(Debug)] #[derive(Debug, Clone)]
pub enum Event { pub enum Event {
Shutdown, Shutdown,
StartFile, StartFile,
@ -30,7 +30,7 @@ pub enum Event {
Unimplemented, Unimplemented,
} }
#[derive(Debug)] #[derive(Debug, Clone)]
pub enum Property { pub enum Property {
Path(Option<String>), Path(Option<String>),
Pause(bool), Pause(bool),
@ -40,6 +40,7 @@ pub enum Property {
Unknown { name: String, data: MpvDataType }, Unknown { name: String, data: MpvDataType },
} }
#[derive(Debug, Clone)]
pub enum MpvCommand { pub enum MpvCommand {
LoadFile { LoadFile {
file: String, file: String,
@ -76,7 +77,7 @@ pub enum MpvCommand {
Unobserve(isize), Unobserve(isize),
} }
#[derive(Debug)] #[derive(Debug, Clone)]
pub enum MpvDataType { pub enum MpvDataType {
Array(Vec<MpvDataType>), Array(Vec<MpvDataType>),
Bool(bool), Bool(bool),
@ -88,22 +89,26 @@ pub enum MpvDataType {
Usize(usize), Usize(usize),
} }
#[derive(Debug, Clone)]
pub enum NumberChangeOptions { pub enum NumberChangeOptions {
Absolute, Absolute,
Increase, Increase,
Decrease, Decrease,
} }
#[derive(Debug, Clone, Copy)]
pub enum PlaylistAddOptions { pub enum PlaylistAddOptions {
Replace, Replace,
Append, Append,
} }
#[derive(Debug, Clone, Copy)]
pub enum PlaylistAddTypeOptions { pub enum PlaylistAddTypeOptions {
File, File,
Playlist, Playlist,
} }
#[derive(Debug, Clone, Copy)]
pub enum SeekOptions { pub enum SeekOptions {
Relative, Relative,
Absolute, Absolute,
@ -111,13 +116,14 @@ pub enum SeekOptions {
AbsolutePercent, AbsolutePercent,
} }
#[derive(Debug, Clone, Copy)]
pub enum Switch { pub enum Switch {
On, On,
Off, Off,
Toggle, Toggle,
} }
#[derive(Debug)] #[derive(Debug, Clone)]
pub enum ErrorCode { pub enum ErrorCode {
MpvError(String), MpvError(String),
JsonParseError(String), JsonParseError(String),
@ -140,9 +146,9 @@ pub struct Mpv {
reader: BufReader<UnixStream>, reader: BufReader<UnixStream>,
name: String, name: String,
} }
#[derive(Debug)] #[derive(Debug, Clone)]
pub struct Playlist(pub Vec<PlaylistEntry>); pub struct Playlist(pub Vec<PlaylistEntry>);
#[derive(Debug)] #[derive(Debug, Clone)]
pub struct Error(pub ErrorCode); pub struct Error(pub ErrorCode);
impl Drop for Mpv { impl Drop for Mpv {
@ -363,8 +369,7 @@ impl Mpv {
/// Ok(()) /// Ok(())
/// } /// }
/// ``` /// ```
pub fn get_property<T: GetPropertyTypeHandler>(&self, property: &str) -> Result<T, Error> { pub fn get_property<T: GetPropertyTypeHandler>(&self, property: &str) -> Result<T, Error> { T::get_property_generic(self, property)
T::get_property_generic(self, property)
} }
/// # Description /// # Description