mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
76 lines
2 KiB
Rust
76 lines
2 KiB
Rust
#![feature(type_alias_impl_trait)]
|
|
|
|
mod time; pub use self::time::*;
|
|
mod note; pub use self::note::*;
|
|
pub mod jack; pub use self::jack::*;
|
|
pub mod midi; pub use self::midi::*;
|
|
|
|
pub(crate) use std::sync::{Arc, RwLock, atomic::{AtomicUsize, AtomicBool, Ordering::Relaxed}};
|
|
pub(crate) use std::path::PathBuf;
|
|
pub(crate) use std::fmt::Debug;
|
|
pub(crate) use std::ops::{Add, Sub, Mul, Div, Rem};
|
|
|
|
pub(crate) use ::tengri::input::*;
|
|
pub(crate) use ::tengri::output::*;
|
|
pub(crate) use ::tengri::dsl::*;
|
|
pub(crate) use ::tengri::tui::*;
|
|
pub(crate) use ::tengri::tui::ratatui::style::{Style, Stylize, Color};
|
|
|
|
pub use ::atomic_float; pub(crate) use atomic_float::*;
|
|
|
|
/// Standard result type.
|
|
pub(crate) type Usually<T> = std::result::Result<T, Box<dyn std::error::Error>>;
|
|
|
|
/// Standard optional result type.
|
|
pub(crate) type Perhaps<T> = std::result::Result<Option<T>, Box<dyn std::error::Error>>;
|
|
|
|
pub trait Gettable<T> {
|
|
/// Returns current value
|
|
fn get (&self) -> T;
|
|
}
|
|
|
|
pub trait Mutable<T>: Gettable<T> {
|
|
/// Sets new value, returns old
|
|
fn set (&mut self, value: T) -> T;
|
|
}
|
|
|
|
pub trait InteriorMutable<T>: Gettable<T> {
|
|
/// Sets new value, returns old
|
|
fn set (&self, value: T) -> T;
|
|
}
|
|
|
|
impl Gettable<bool> for AtomicBool {
|
|
fn get (&self) -> bool { self.load(Relaxed) }
|
|
}
|
|
|
|
impl InteriorMutable<bool> for AtomicBool {
|
|
fn set (&self, value: bool) -> bool { self.swap(value, Relaxed) }
|
|
}
|
|
|
|
impl Gettable<usize> for AtomicUsize {
|
|
fn get (&self) -> usize { self.load(Relaxed) }
|
|
}
|
|
|
|
impl InteriorMutable<usize> for AtomicUsize {
|
|
fn set (&self, value: usize) -> usize { self.swap(value, Relaxed) }
|
|
}
|
|
|
|
#[cfg(test)] #[test] fn test_time () -> Usually<()> {
|
|
// TODO!
|
|
Ok(())
|
|
}
|
|
|
|
#[cfg(test)] #[test] fn test_midi_range () {
|
|
let model = MidiRangeModel::from((1, false));
|
|
|
|
let _ = model.time_len();
|
|
let _ = model.time_zoom();
|
|
let _ = model.time_lock();
|
|
let _ = model.time_start();
|
|
let _ = model.time_axis();
|
|
let _ = model.time_end();
|
|
|
|
let _ = model.note_lo();
|
|
let _ = model.note_axis();
|
|
let _ = model.note_hi();
|
|
}
|