mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
refactor into fewer crates, pt.2
This commit is contained in:
parent
77703d83a5
commit
a22a793c31
48 changed files with 2155 additions and 2157 deletions
76
crates/engine/src/lib.rs
Normal file
76
crates/engine/src/lib.rs
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
#![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();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue