5 unstable releases
0.2.2 | May 3, 2019 |
---|---|
0.2.1 | Apr 25, 2019 |
0.2.0 | Apr 7, 2019 |
0.1.0 | Feb 26, 2019 |
0.0.0 | Feb 21, 2019 |
#6 in #adaptation
Used in 3 crates
51KB
581 lines
lv2rs-urid: Rust adaptation prototype of the LV2 urid library.
This is a safe and idiomatic re-implementation of the LV2 urid library. It provides means to map URIs to integer numbers, which improves their speed and memory footprint.
This is a frozen prototype and therefore, development of this crate will not continue here. Further development continues as rust-lv2.
Getting started
If you want to get started with LV2, you should start with the root crate and check out the [book](https://janonard.github.io/lv2rs-book/.
lib.rs
:
A Rust re-implementation of the LV2 URID library.
This LV2 feature enables you to map URIs to numbers and reverse.
This is a frozen prototype and therefore, development of this crate will not continue here. Further development continues as rust-lv2.
Use
URID mapping is only possible in the instantiate
function of a plugin since there is no
guarantee that the required pointers live longer than the instantiate
function call. Here is
an example:
// import the required crates.
extern crate lv2rs_core as core;
extern crate lv2rs_urid as urid;
use std::ffi::CStr;
// A dummy plugin that doesn't actually do anything.
struct UridPlugin {}
impl core::Plugin for UridPlugin {
fn instantiate(
descriptor: &core::Descriptor,
rate: f64,
bundle_path: &CStr,
features: Option<&core::FeaturesList>
) -> Option<Self> where Self: Sized {
// Return `None` if there are no features.
let features = features?;
// Try to get the mapper and the un-mapper from the features list.
let map = urid::Map::try_from_features(features)?;
let unmap = urid::Unmap::try_from_features(features)?;
// Create a URI, map it, and un-map it.
let github_uri = CStr::from_bytes_with_nul(b"https://github.com\0").unwrap();
let github_urid = map.map(github_uri);
let github_uri = unmap.unmap(github_urid);
Some(Self {})
}
// Blank implementations to keep the compiler quiet.
fn connect_port(&mut self, _port: u32, _data: *mut ()) {}
fn run(&mut self, _n_samples: u32) {}
}