cargo fmt

This commit is contained in:
Nolan Darilek 2019-01-03 16:16:54 +00:00
parent 103a0c043d
commit e82a10ba16
3 changed files with 11 additions and 14 deletions

View File

@ -1,5 +1,4 @@
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
use std::u8; use std::u8;
use log::{info, trace}; use log::{info, trace};
@ -18,7 +17,7 @@ impl SpeechDispatcher {
} }
fn u8_to_i32(v: u8) -> i32 { fn u8_to_i32(v: u8) -> i32 {
let ratio: f32 = v as f32/u8::MAX as f32; let ratio: f32 = v as f32 / u8::MAX as f32;
(ratio * 200. - 100.) as i32 (ratio * 200. - 100.) as i32
} }

View File

@ -1,5 +1,4 @@
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
use std::u8; use std::u8;
use log::{info, trace}; use log::{info, trace};

View File

@ -51,10 +51,9 @@ trait Backend {
pub struct TTS(Box<Backend>); pub struct TTS(Box<Backend>);
impl TTS { impl TTS {
/** /**
* Create a new `TTS` instance with the specified backend. * Create a new `TTS` instance with the specified backend.
*/ */
pub fn new(backend: Backends) -> Result<TTS, Error> { pub fn new(backend: Backends) -> Result<TTS, Error> {
match backend { match backend {
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
@ -63,7 +62,7 @@ impl TTS {
Backends::Web => { Backends::Web => {
let tts = backends::Web::new()?; let tts = backends::Web::new()?;
Ok(TTS(Box::new(tts))) Ok(TTS(Box::new(tts)))
}, }
} }
} }
@ -77,7 +76,7 @@ impl TTS {
/** /**
* Speaks the specified text, optionally interrupting current speech. * Speaks the specified text, optionally interrupting current speech.
*/ */
pub fn speak<S: Into<String>>(&self, text: S, interrupt: bool) -> Result<&Self, Error> { pub fn speak<S: Into<String>>(&self, text: S, interrupt: bool) -> Result<&Self, Error> {
self.0.speak(text.into().as_str(), interrupt)?; self.0.speak(text.into().as_str(), interrupt)?;
Ok(self) Ok(self)
@ -85,7 +84,7 @@ impl TTS {
/** /**
* Stops current speech. * Stops current speech.
*/ */
pub fn stop(&self) -> Result<&Self, Error> { pub fn stop(&self) -> Result<&Self, Error> {
self.0.stop()?; self.0.stop()?;
Ok(self) Ok(self)
@ -93,14 +92,14 @@ impl TTS {
/** /**
* Gets the current speech rate. * Gets the current speech rate.
*/ */
pub fn get_rate(&self) -> Result<u8, Error> { pub fn get_rate(&self) -> Result<u8, Error> {
self.0.get_rate() self.0.get_rate()
} }
/** /**
* Sets the desired speech rate. * Sets the desired speech rate.
*/ */
pub fn set_rate(&mut self, rate: u8) -> Result<&Self, Error> { pub fn set_rate(&mut self, rate: u8) -> Result<&Self, Error> {
self.0.set_rate(rate)?; self.0.set_rate(rate)?;
Ok(self) Ok(self)
@ -108,14 +107,14 @@ impl TTS {
/** /**
* Gets the current speech pitch. * Gets the current speech pitch.
*/ */
pub fn get_pitch(&self) -> Result<u8, Error> { pub fn get_pitch(&self) -> Result<u8, Error> {
self.0.get_pitch() self.0.get_pitch()
} }
/** /**
* Sets the desired speech pitch. * Sets the desired speech pitch.
*/ */
pub fn set_pitch(&mut self, pitch: u8) -> Result<&Self, Error> { pub fn set_pitch(&mut self, pitch: u8) -> Result<&Self, Error> {
self.0.set_pitch(pitch)?; self.0.set_pitch(pitch)?;
Ok(self) Ok(self)
@ -123,14 +122,14 @@ impl TTS {
/** /**
* Gets the current speech volume. * Gets the current speech volume.
*/ */
pub fn get_volume(&self) -> Result<u8, Error> { pub fn get_volume(&self) -> Result<u8, Error> {
self.0.get_volume() self.0.get_volume()
} }
/** /**
* Sets the desired speech volume. * Sets the desired speech volume.
*/ */
pub fn set_volume(&mut self, volume: u8) -> Result<&Self, Error> { pub fn set_volume(&mut self, volume: u8) -> Result<&Self, Error> {
self.0.set_volume(volume)?; self.0.set_volume(volume)?;
Ok(self) Ok(self)