[][src]Module lv2_atom::vector

An atom containg an array of scalar atom bodies.

This atom is able to handle arrays (aka slices) of the internal types of scalar atoms.

Reading a vector requires the URID fo the scalar that's been used and the reading process fails if the vector does not contain the requested scalar atom. The return value of the reading process is a slice of the internal type.

Writing a vector is done with a writer that appends slices to the atom.

Example

use lv2_core::prelude::*;
use lv2_atom::prelude::*;
use lv2_atom::vector::VectorWriter;

#[derive(PortCollection)]
struct MyPorts {
    input: InputPort<AtomPort>,
    output: OutputPort<AtomPort>,
}

fn run(ports: &mut MyPorts, urids: &AtomURIDCollection) {
    let input: &[i32] = ports.input.read(urids.vector(), urids.int).unwrap();
    let mut output: VectorWriter<Int> = ports.output.init(urids.vector(), urids.int).unwrap();
    output.append(input).unwrap();
}

You may note that, unlike other atoms, the vector's URID is retrieved by calling the vector method. This is because two vectors with a different item type are considered two different types, and therefore would have the different URIDs. In reality, however, all vectors have the same URID and the vector method returns it with the fitting type.

Specification

http://lv2plug.in/ns/ext/atom/atom.html#Vector

Structs

Vector

An atom containg an array of scalar atom bodies.

VectorWriter

Handle to append elements to a vector.