refactor: jack proto-lib

This commit is contained in:
🪞👃🪞 2024-07-04 15:32:41 +03:00
parent 4aadc712b8
commit fe6ffea5df
12 changed files with 467 additions and 441 deletions

View file

@ -1,30 +1,27 @@
pub use std::error::Error;
pub use std::io::{stdout, Stdout, Write};
pub use std::thread::{spawn, JoinHandle};
pub use std::time::Duration;
pub use std::collections::BTreeMap;
pub use std::sync::{Arc, Mutex, MutexGuard};
pub use std::sync::atomic::{Ordering, AtomicBool, AtomicUsize};
pub use std::sync::mpsc::{channel, Sender, Receiver};
/// Define and reexport submodules.
#[macro_export] macro_rules! submod {
($($name:ident)*) => { $(mod $name; pub use self::$name::*;)* };
}
pub use microxdg::XdgApp;
pub use ratatui::prelude::*;
pub use midly::{MidiMessage, live::LiveEvent, num::u7};
pub use crossterm::{ExecutableCommand, QueueableCommand};
pub use crossterm::event::{Event, KeyEvent, KeyCode, KeyModifiers};
macro_rules! submod { ($($name:ident)*) => { $(mod $name; pub use self::$name::*;)* }; }
submod!( handle jack keymap midi port render run time );
submod!( handle keymap midi render run time );
/// Standard result type.
pub type Usually<T> = Result<T, Box<dyn Error>>;
pub trait Component: Render + Handle {}
/// A UI component.
pub trait Component: Render + Handle {
/// Perform type erasure for collecting heterogeneous components.
fn boxed (self) -> Box<dyn Component> where Self: Sized + 'static {
Box::new(self)
}
}
/// Anything that implements `Render` + `Handle` can be used as a UI component.
impl<T: Render + Handle> Component for T {}
/// A UI component that may have presence on the JACK grap.
/// A UI component that may be associated with a JACK client by the `Jack` factory.
pub trait Device: Render + Handle + Process + Send + Sync {
/// Perform type erasure for collecting heterogeneous devices.
fn boxed (self) -> Box<dyn Device> where Self: Sized + 'static {
Box::new(self)
}
@ -34,12 +31,24 @@ pub trait Device: Render + Handle + Process + Send + Sync {
impl<T: Render + Handle + Process + Send + Sync> Device for T {}
// Reexport macros:
pub use crate::{
render,
handle,
process,
phrase,
keymap,
key,
ports
};
pub use crate::{submod, render, handle, process, phrase, keymap, key, ports};
// Reexport JACK proto-lib:
pub use crate::jack::*;
// Various stdlib dependencies:
pub use std::error::Error;
pub use std::io::{stdout, Stdout, Write};
pub use std::thread::{spawn, JoinHandle};
pub use std::time::Duration;
pub use std::collections::BTreeMap;
pub use std::sync::{Arc, Mutex, MutexGuard};
pub use std::sync::atomic::{Ordering, AtomicBool, AtomicUsize};
pub use std::sync::mpsc::{channel, Sender, Receiver};
// Various non-stdlib dependencies:
pub use microxdg::XdgApp;
pub use ratatui::prelude::*;
pub use midly::{MidiMessage, live::LiveEvent, num::u7};
pub use crossterm::{ExecutableCommand, QueueableCommand};
pub use crossterm::event::{Event, KeyEvent, KeyCode, KeyModifiers};