Add `Default` implementation for `Features` so backends need only specify features they actually support.

This commit is contained in:
Nolan Darilek 2020-08-24 16:44:00 -05:00
parent 951e31b284
commit 1507527175
3 changed files with 14 additions and 5 deletions

View File

@ -95,9 +95,9 @@ impl Backend for AppKit {
Features { Features {
stop: true, stop: true,
rate: true, rate: true,
pitch: false,
volume: true, volume: true,
is_speaking: true, is_speaking: true,
..Default::default(),
} }
} }

View File

@ -22,10 +22,7 @@ impl Backend for Tolk {
fn supported_features(&self) -> Features { fn supported_features(&self) -> Features {
Features { Features {
stop: true, stop: true,
rate: false, ..Default::default(),
pitch: false,
volume: false,
is_speaking: false,
} }
} }

View File

@ -48,6 +48,18 @@ pub struct Features {
pub is_speaking: bool, pub is_speaking: bool,
} }
impl Default for Features {
fn default() -> Self {
Self {
stop: false,
rate: false,
pitch: false,
volume: false,
is_speaking: false,
}
}
}
#[derive(Debug, Error)] #[derive(Debug, Error)]
pub enum Error { pub enum Error {
#[error("IO error: {0}")] #[error("IO error: {0}")]