pub mod api;
pub mod macros;
pub mod properties;
pub use api::*;
pub use properties::*;
use fmt::{Display, Formatter};
use std::{error::Error as StdError, fmt};
pub type Error = Box<dyn StdError + Send + Sync + 'static>;
pub type Result<T = (), E = Error> = std::result::Result<T, E>;
#[derive(Debug)]
pub struct ApiError(usize);
impl Display for ApiError {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "Speech API returned error with code: {}", self.0)
}
}
impl StdError for ApiError {}
pub const INVALID_HANDLE: SPXHANDLE = std::usize::MAX as SPXHANDLE;
pub const NULL_HANDLE: SPXHANDLE = 0 as SPXHANDLE;
pub trait Handle<T = SPXHANDLE> {
fn handle(&self) -> T;
}
pub fn from_hr(code: usize) -> Result {
if code == 0 {
Ok(())
} else {
Err(Box::new(ApiError(code)))
}
}