pub struct World { /* private fields */ }Expand description
The world represents all Lilv state. It is used to discover/load/cache LV2 data (plugins, UIs, and extensions).
Implementations§
source§impl World
impl World
sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
fn main() {
let world = World::new();
world.load_all();
let show_names = false;
let print = |plugin: Plugin| {
if show_names {
String::from(plugin.name().as_str().unwrap())
} else {
String::from(plugin.uri().as_uri().unwrap())
}
};
let plugins = world
.plugins()
.iter()
.filter(Plugin::verify)
.map(print)
.collect::<Vec<_>>();
debug_assert_eq!(world.plugins().count(), plugins.len());
for uri in plugins {
println!("{}", uri);
}
}More examples
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
fn main() {
let w = World::new();
w.load_all();
let nodes = Nodes {
control_class: w.new_uri("http://lv2plug.in/ns/lv2core#ControlPort"),
event_class: w.new_uri("http://lv2plug.in/ns/ext/atom#AtomPort"),
group_pred: w.new_uri("http://lv2plug.in/ns/ext/port-groups#group"),
label_pred: w.new_uri("http://www.w3.org/2000/01/rdf-schema#label"),
preset_class: w.new_uri("http://lv2plug.in/ns/ext/presets#Preset"),
designation_pred: w.new_uri("http://lv2plug.in/ns/lv2core#designation"),
supports_event_pred: w.new_uri("http://lv2plug.in/ns/ext/atom#supportsEvent"),
};
for p in w.plugins().iter().filter(Plugin::verify) {
print_plugin(&w, &p, &nodes);
}
}sourcepub fn with_load_all() -> World
pub fn with_load_all() -> World
Loads a new world with all the installed LV2 bundles on the system.
Example
let world = lilv::World::new();
world.load_all();source§impl World
impl World
sourcepub fn plugin_class(&self) -> Option<Class>
pub fn plugin_class(&self) -> Option<Class>
Get the parent of all other plugin classes, lv2:Plugin.
sourcepub fn plugins(&self) -> Plugins
pub fn plugins(&self) -> Plugins
An iterable over all the plugins in the world.
Examples found in repository?
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
fn main() {
let world = World::new();
world.load_all();
let show_names = false;
let print = |plugin: Plugin| {
if show_names {
String::from(plugin.name().as_str().unwrap())
} else {
String::from(plugin.uri().as_uri().unwrap())
}
};
let plugins = world
.plugins()
.iter()
.filter(Plugin::verify)
.map(print)
.collect::<Vec<_>>();
debug_assert_eq!(world.plugins().count(), plugins.len());
for uri in plugins {
println!("{}", uri);
}
}More examples
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
fn main() {
let w = World::new();
w.load_all();
let nodes = Nodes {
control_class: w.new_uri("http://lv2plug.in/ns/lv2core#ControlPort"),
event_class: w.new_uri("http://lv2plug.in/ns/ext/atom#AtomPort"),
group_pred: w.new_uri("http://lv2plug.in/ns/ext/port-groups#group"),
label_pred: w.new_uri("http://www.w3.org/2000/01/rdf-schema#label"),
preset_class: w.new_uri("http://lv2plug.in/ns/ext/presets#Preset"),
designation_pred: w.new_uri("http://lv2plug.in/ns/lv2core#designation"),
supports_event_pred: w.new_uri("http://lv2plug.in/ns/ext/atom#supportsEvent"),
};
for p in w.plugins().iter().filter(Plugin::verify) {
print_plugin(&w, &p, &nodes);
}
}source§impl World
impl World
sourcepub fn new_uri(&self, uri: &str) -> Node
pub fn new_uri(&self, uri: &str) -> Node
Examples found in repository?
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
fn main() {
let w = World::new();
w.load_all();
let nodes = Nodes {
control_class: w.new_uri("http://lv2plug.in/ns/lv2core#ControlPort"),
event_class: w.new_uri("http://lv2plug.in/ns/ext/atom#AtomPort"),
group_pred: w.new_uri("http://lv2plug.in/ns/ext/port-groups#group"),
label_pred: w.new_uri("http://www.w3.org/2000/01/rdf-schema#label"),
preset_class: w.new_uri("http://lv2plug.in/ns/ext/presets#Preset"),
designation_pred: w.new_uri("http://lv2plug.in/ns/lv2core#designation"),
supports_event_pred: w.new_uri("http://lv2plug.in/ns/ext/atom#supportsEvent"),
};
for p in w.plugins().iter().filter(Plugin::verify) {
print_plugin(&w, &p, &nodes);
}
}sourcepub fn new_string(&self, string: &str) -> Node
pub fn new_string(&self, string: &str) -> Node
source§impl World
impl World
sourcepub fn load_all(&self)
pub fn load_all(&self)
Loads all installed LV2 bundles on the system.
Example
let world = lilv::World::new();
world.load_all();Examples found in repository?
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
fn main() {
let world = World::new();
world.load_all();
let show_names = false;
let print = |plugin: Plugin| {
if show_names {
String::from(plugin.name().as_str().unwrap())
} else {
String::from(plugin.uri().as_uri().unwrap())
}
};
let plugins = world
.plugins()
.iter()
.filter(Plugin::verify)
.map(print)
.collect::<Vec<_>>();
debug_assert_eq!(world.plugins().count(), plugins.len());
for uri in plugins {
println!("{}", uri);
}
}More examples
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
fn main() {
let w = World::new();
w.load_all();
let nodes = Nodes {
control_class: w.new_uri("http://lv2plug.in/ns/lv2core#ControlPort"),
event_class: w.new_uri("http://lv2plug.in/ns/ext/atom#AtomPort"),
group_pred: w.new_uri("http://lv2plug.in/ns/ext/port-groups#group"),
label_pred: w.new_uri("http://www.w3.org/2000/01/rdf-schema#label"),
preset_class: w.new_uri("http://lv2plug.in/ns/ext/presets#Preset"),
designation_pred: w.new_uri("http://lv2plug.in/ns/lv2core#designation"),
supports_event_pred: w.new_uri("http://lv2plug.in/ns/ext/atom#supportsEvent"),
};
for p in w.plugins().iter().filter(Plugin::verify) {
print_plugin(&w, &p, &nodes);
}
}sourcepub fn load_bundle(&self, bundle_uri: &Node)
pub fn load_bundle(&self, bundle_uri: &Node)
Loads a specific bundle. bundle_uri must be a fully qualified URI to the bundle directory,
with the trailing slash, eg file:///usr/lib/lv2/foo.lv2/.
sourcepub fn load_specifications(&self)
pub fn load_specifications(&self)
Loads all specifications from currently loaded bundles.
This is for hosts that explicitly load specific bundles, its use is not
necessary when using load_all. This function parses the specifications
and adds them to the model.
sourcepub fn load_plugin_classes(&self)
pub fn load_plugin_classes(&self)
Load all plugin classes from currently loaded specifications.
Must be called after load_specifications. This is for hosts
that explicitly load specific bundles; its use is not necessary when using
load_all.
sourcepub unsafe fn unload_bundle(&self, bundle_uri: &Node) -> bool
pub unsafe fn unload_bundle(&self, bundle_uri: &Node) -> bool
Unload a specific bundle.
This unloads statements loaded by load_bundle. Note this is not necessarily all
information loaded from the bundle. If any resources have been separately loaded with
load_resource, they must be separately unloaded with
unload_resource.
Safety
Unloading bundles that are in use by the host will cause undefined behaviour.
sourcepub fn load_resource(&self, resource: &Node) -> Option<usize>
pub fn load_resource(&self, resource: &Node) -> Option<usize>
Examples found in repository?
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
fn print_plugin(world: &World, p: &Plugin, nodes: &Nodes) {
println!("{}\n", p.uri().as_uri().unwrap());
println!("\tName: {}", p.name().as_str().unwrap());
println!(
"\tClass: {}",
p.class().label().as_str().unwrap()
);
if let Some(val) = p.author_name() {
println!("\tAuthor: {}", val.as_str().unwrap());
}
if let Some(val) = p.author_email() {
println!("\tAuthor Email: {}", val.as_str().unwrap());
}
if let Some(val) = p.author_homepage() {
println!("\tAuthor Homepage: {}", val.as_uri().unwrap());
}
if let Some(latency_port) = p.latency_port_index() {
println!(
"\tHas latency: yes, reported by port {}",
latency_port
);
} else {
println!("\tHas latency: no");
}
println!("\tBundle: {}", p.bundle_uri().as_uri().unwrap());
println!(
"\tBinary: {}",
p.library_uri().map_or("<none>".to_string(), |node| node
.as_uri()
.unwrap()
.to_string())
);
if let Some(uis) = p.uis() {
println!("\tUIs:");
for ui in uis {
println!("\t\t{}", ui.uri().as_uri().unwrap());
for tyep in ui.classes() {
println!("\t\t\tClass: {}", tyep.as_uri().unwrap());
}
println!(
"\t\t\tBinary: {}",
ui.binary_uri().unwrap().as_uri().unwrap()
);
println!(
"\t\t\tBundle: {}",
ui.bundle_uri().unwrap().as_uri().unwrap()
);
}
}
print!("\tData URIs: ");
for (i, uri) in p.data_uris().iter().enumerate() {
if i != 0 {
print!("\n\t ");
}
print!("{}", uri.as_uri().unwrap());
}
println!();
let features = p.required_features();
print!("\tRequired Features: ");
for (i, feature) in features.iter().enumerate() {
if i != 0 {
print!("\n\t ");
}
print!("{}", feature.as_uri().unwrap());
}
println!();
let features = p.optional_features();
print!("\tOptional Features: ");
for (i, feature) in features.iter().enumerate() {
if i != 0 {
print!("\n\t ");
}
print!("{}", feature.as_uri().unwrap());
}
println!();
if let Some(data) = p.extension_data() {
print!("\tExtension Data: ");
for (i, d) in data.iter().enumerate() {
if i != 0 {
print!("\n\t ");
}
print!("{}", d.as_uri().unwrap());
}
println!();
}
if let Some(presets) = p.related(Some(&nodes.preset_class)) {
if presets.count() != 0 {
println!("\tPresets: ");
for preset in presets {
world.load_resource(&preset).unwrap();
let titles = world.find_nodes(Some(&preset), &nodes.label_pred, None);
if titles.count() > 0 {
if let Some(title) = titles.iter().next() {
println!("\t {}", title.as_str().unwrap());
} else {
println!("\t <{}>", preset.as_uri().unwrap());
}
} else {
println!("\t <{}>", preset.as_uri().unwrap());
}
}
}
}
let num_ports = p.ports_count();
let port_ranges = p.port_ranges_float();
assert_eq!(num_ports, port_ranges.len());
for (i, pr) in port_ranges.iter().enumerate() {
print_port(p, i, pr, nodes);
}
}sourcepub unsafe fn unload_resource(&self, resource: &Node) -> bool
pub unsafe fn unload_resource(&self, resource: &Node) -> bool
Unload all the data associated with the given resource.
Safety
Unloading resources that are in use by the host will cause undefined behaviour.
source§impl World
impl World
sourcepub fn find_nodes(
&self,
subject: Option<&Node>,
predicate: &Node,
object: Option<&Node>
) -> Nodes
pub fn find_nodes( &self, subject: Option<&Node>, predicate: &Node, object: Option<&Node> ) -> Nodes
Find nodes matching a triple pattern. Either subject or object may be None, but not both.
Examples found in repository?
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
fn print_plugin(world: &World, p: &Plugin, nodes: &Nodes) {
println!("{}\n", p.uri().as_uri().unwrap());
println!("\tName: {}", p.name().as_str().unwrap());
println!(
"\tClass: {}",
p.class().label().as_str().unwrap()
);
if let Some(val) = p.author_name() {
println!("\tAuthor: {}", val.as_str().unwrap());
}
if let Some(val) = p.author_email() {
println!("\tAuthor Email: {}", val.as_str().unwrap());
}
if let Some(val) = p.author_homepage() {
println!("\tAuthor Homepage: {}", val.as_uri().unwrap());
}
if let Some(latency_port) = p.latency_port_index() {
println!(
"\tHas latency: yes, reported by port {}",
latency_port
);
} else {
println!("\tHas latency: no");
}
println!("\tBundle: {}", p.bundle_uri().as_uri().unwrap());
println!(
"\tBinary: {}",
p.library_uri().map_or("<none>".to_string(), |node| node
.as_uri()
.unwrap()
.to_string())
);
if let Some(uis) = p.uis() {
println!("\tUIs:");
for ui in uis {
println!("\t\t{}", ui.uri().as_uri().unwrap());
for tyep in ui.classes() {
println!("\t\t\tClass: {}", tyep.as_uri().unwrap());
}
println!(
"\t\t\tBinary: {}",
ui.binary_uri().unwrap().as_uri().unwrap()
);
println!(
"\t\t\tBundle: {}",
ui.bundle_uri().unwrap().as_uri().unwrap()
);
}
}
print!("\tData URIs: ");
for (i, uri) in p.data_uris().iter().enumerate() {
if i != 0 {
print!("\n\t ");
}
print!("{}", uri.as_uri().unwrap());
}
println!();
let features = p.required_features();
print!("\tRequired Features: ");
for (i, feature) in features.iter().enumerate() {
if i != 0 {
print!("\n\t ");
}
print!("{}", feature.as_uri().unwrap());
}
println!();
let features = p.optional_features();
print!("\tOptional Features: ");
for (i, feature) in features.iter().enumerate() {
if i != 0 {
print!("\n\t ");
}
print!("{}", feature.as_uri().unwrap());
}
println!();
if let Some(data) = p.extension_data() {
print!("\tExtension Data: ");
for (i, d) in data.iter().enumerate() {
if i != 0 {
print!("\n\t ");
}
print!("{}", d.as_uri().unwrap());
}
println!();
}
if let Some(presets) = p.related(Some(&nodes.preset_class)) {
if presets.count() != 0 {
println!("\tPresets: ");
for preset in presets {
world.load_resource(&preset).unwrap();
let titles = world.find_nodes(Some(&preset), &nodes.label_pred, None);
if titles.count() > 0 {
if let Some(title) = titles.iter().next() {
println!("\t {}", title.as_str().unwrap());
} else {
println!("\t <{}>", preset.as_uri().unwrap());
}
} else {
println!("\t <{}>", preset.as_uri().unwrap());
}
}
}
}
let num_ports = p.ports_count();
let port_ranges = p.port_ranges_float();
assert_eq!(num_ports, port_ranges.len());
for (i, pr) in port_ranges.iter().enumerate() {
print_port(p, i, pr, nodes);
}
}sourcepub fn get(
&self,
subject: Option<&Node>,
predicate: Option<&Node>,
object: Option<&Node>
) -> Option<Node>
pub fn get( &self, subject: Option<&Node>, predicate: Option<&Node>, object: Option<&Node> ) -> Option<Node>
Find a single node that matches a pattern. Exactly one of subject, predicate, or
object must be None.