libmapper_rs/
lib.rs

1//! # libmapper-rs
2//! 
3//! libmapper is a cross-platform library for connecting data sources to synthesizers, DAWs, and other hardware or software devices.
4//! It provides a simple API for creating and managing signals, devices, and mappings between them.
5//! 
6//! This project contains safe, idiomatic rust bindings to the libmapper C api.
7//! 
8//! ## Concepts
9//! ### [Devices](device)
10//! Libmapper operates on a shared peer-to-peer graph. A [Device](device::Device) represents a connection to this graph and is a container for signals.
11//! 
12//! Most libmapper code will start by creating a device and polling until it becomes ready, like so:
13//! ```
14//! use libmapper_rs::device::Device;
15//! fn main() {
16//!     let mut device = Device::create("CoolDevice");
17//!     loop {
18//!       device.poll_and_block(std::time::Duration::from_millis(10));
19//!       if device.is_ready() {
20//!          break;
21//!         }
22//!     }
23//!     println!("Device is ready!");
24//!     // create signals, maps, etc.
25//! }
26//! ```
27
28use bindings::mpr_get_version;
29
30pub mod device;
31pub mod graph;
32pub mod signal;
33pub mod object;
34
35mod util;
36
37pub mod constants {
38    pub use crate::bindings::mpr_dir;
39    pub use crate::bindings::mpr_type;
40    pub use crate::bindings::mpr_prop;
41}
42mod bindings;
43
44/// Get the version of the loaded libmapper library.
45pub fn get_mapper_version() -> &'static str {
46    unsafe {
47        let version = mpr_get_version();
48        std::ffi::CStr::from_ptr::<'static>(version).to_str().unwrap()
49    }
50}