Common traits for Features

This commit is contained in:
Raimundo Saona 2021-12-22 13:28:00 +01:00
parent d24d1a6a15
commit 9ed03753c2
2 changed files with 20 additions and 4 deletions

View File

@ -16,6 +16,7 @@ dyn-clonable = "0.9"
lazy_static = "1"
log = "0.4"
thiserror = "1"
serde = { version = "1.0", optional = true, features = ["derive"] }
[dev-dependencies]
env_logger = "0.9"

View File

@ -16,6 +16,7 @@ use std::boxed::Box;
use std::collections::HashMap;
#[cfg(target_os = "macos")]
use std::ffi::CStr;
use std::fmt;
use std::sync::Mutex;
#[cfg(any(target_os = "macos", target_os = "ios"))]
@ -84,13 +85,15 @@ unsafe impl Send for UtteranceId {}
unsafe impl Sync for UtteranceId {}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Features {
pub stop: bool,
pub rate: bool,
pub pitch: bool,
pub volume: bool,
pub is_speaking: bool,
pub pitch: bool,
pub rate: bool,
pub stop: bool,
pub utterance_callbacks: bool,
pub volume: bool,
}
impl Default for Features {
@ -106,6 +109,18 @@ impl Default for Features {
}
}
impl fmt::Display for Features {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
writeln!(f, "{:#?}", self)
}
}
impl Features {
pub fn new() -> Self {
Self::default()
}
}
#[derive(Debug, Error)]
pub enum Error {
#[error("IO error: {0}")]