pub enum ArgData<'a, 'b> {
Show 23 variants
Float(Float),
Floats(Floats<'a>),
Double(Double),
Doubles(Doubles<'a>),
Integer(Integer),
Integers(Integers<'a>),
String(String),
Strings(Strings),
Color(Color<'a>),
Colors(Colors<'a>),
Point(Point<'a>),
Points(Points<'a>),
Vector(Vector<'a>),
Vectors(Vectors<'a>),
Normal(Normal<'a>),
Normals(Normals<'a>),
Matrix(Matrix<'a>),
Matrices(Matrices<'a>),
DoubleMatrix(DoubleMatrix<'a>),
DoubleMatrices(DoubleMatrices<'a>),
Reference(Reference<'b>),
References(References<'b>),
Callback(Callback<'b>),
}Expand description
A variant describing data passed to the renderer.
§Lifetimes
Lifetime 'a is for any tuple or array type as these are
passed as references and only need to live as long as the
function call where they get passed.
Lifetime 'b is for the arbitrary reference type. This is
pegged to the lifetime of the Context.
Use this to pass arbitrary Rust data through the FFI boundary.
Variants§
Float(Float)
Single f32 value.
Floats(Floats<'a>)
An [f32] slice.
Double(Double)
Single f64 value.
Doubles(Doubles<'a>)
An [f64] slice.
Integer(Integer)
Single i32 value.
Integers(Integers<'a>)
An [i32] slice.
String(String)
A String.
Strings(Strings)
A [String] slice.
Color(Color<'a>)
Color in linear space, given as a red, green, blue triplet
of f32 values; usually in the range 0..1.
Colors(Colors<'a>)
A flat [f32] slice of colors (len % 3 == 0).
Point(Point<'a>)
Point, given as three f32 values.
Points(Points<'a>)
A flat [f32] slice of points (len % 3 == 0).
Vector(Vector<'a>)
Vector, given as three f32 values.
Vectors(Vectors<'a>)
A flat [f32] slice of vectors (len % 3 == 0).
Normal(Normal<'a>)
Normal vector, given as three f32 values.
Normals(Normals<'a>)
A flat [f32] slice of normals (len % 3 == 0).
Matrix(Matrix<'a>)
Row-major, 4×4 transformation matrix, given as 16 f32 values.
Matrices(Matrices<'a>)
A flat [f32] slice of matrices (len % 16 == 0).
DoubleMatrix(DoubleMatrix<'a>)
Row-major, 4×4 transformation matrix, given as 16 f64 values.
DoubleMatrices(DoubleMatrices<'a>)
A flat [f64] slice of matrices (len % 16 == 0).
Reference(Reference<'b>)
Reference with lifetime guarantees.
This gets converted to a raw pointer when passed through the FFI boundary.
let ctx = nsi::Context::new(None).unwrap();
// Lots of scene setup omitted ...
// Setup a custom output driver and send
// a payload to it through the FFI boundary.
ctx.create("driver", nsi::OUTPUT_DRIVER, None);
ctx.connect("driver", None, "beauty", "outputdrivers", None);
struct Payload {
some_data: u32,
}
let payload = Payload { some_data: 42 };
ctx.set_attribute(
"driver",
&[
nsi::string!("drivername", "custom_driver"),
// Payload gets sent as raw pointer through
// the FFI boundary.
nsi::reference!("payload", Pin::new(&payload)),
],
);
// We need to explicitly call drop here as
// ctx's lifetime is pegged to that of payload.
drop(ctx);References(References<'b>)
A [Reference] slice.
Callback(Callback<'b>)
A callback.