#[cfg(feature = "audio")]
use rodio::{OutputStream, Sink};
pub type Res<T> = anyhow::Result<T>;
pub type Err = anyhow::Error;
pub type Void = Res<()>;
pub trait HasStaticName {
fn static_name(&self) -> &'static str;
}
pub trait HasName {
fn name(&self) -> String;
fn name_ascii(&self) -> String {
self.name().replace('♯', "#").replace('♭', "b").replace('𝄪', "##").replace('𝄫', "bb").replace("°", "dim")
}
}
pub trait HasPreciseName {
fn precise_name(&self) -> String;
}
pub trait HasDescription {
fn description(&self) -> &'static str;
}
pub trait Parsable {
fn parse(symbol: &str) -> Res<Self>
where
Self: Sized;
}
#[cfg(feature = "audio")]
pub struct PlaybackHandle {
_stream: OutputStream,
_sinks: Vec<Sink>,
}
#[cfg(feature = "audio")]
impl PlaybackHandle {
pub fn new(stream_handle: OutputStream, sinks: Vec<Sink>) -> Self {
Self { _stream: stream_handle, _sinks: sinks }
}
}
#[cfg(feature = "audio")]
pub trait Playable {
#[must_use = "Dropping the PlayableResult will stop the playback."]
fn play(&self, delay: std::time::Duration, length: std::time::Duration, fade_in: std::time::Duration) -> Res<PlaybackHandle>;
}