pub enum ArgData<'a, 'b> {
Show 26 variants
F32(F32),
F32Slice(F32Slice<'a>),
F64(F64),
F64Slice(F64Slice<'a>),
I32(I32),
I32Slice(I32Slice<'a>),
I64(I64),
I64Slice(I64Slice<'a>),
String(String),
StringSlice(StringSlice),
Color(Color<'a>),
ColorSlice(ColorSlice<'a>),
Point(Point<'a>),
PointSlice(PointSlice<'a>),
Vector(Vector<'a>),
VectorSlice(VectorSlice<'a>),
Normal(Normal<'a>),
NormalSlice(NormalSlice<'a>),
MatrixF32(MatrixF32<'a>),
MatrixF32Slice(MatrixF32Slice<'a>),
MatrixF64(MatrixF64<'a>),
MatrixF64Slice(MatrixF64Slice<'a>),
Point4F32Slice(Point4F32Slice<'a>),
Reference(Reference<'b>),
ReferenceSlice(ReferenceSlice<'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§
F32(F32)
Single [f32] value.
F32Slice(F32Slice<'a>)
An [f32] slice.
F64(F64)
Single [f64] value.
F64Slice(F64Slice<'a>)
An [f64] slice.
I32(I32)
Single [i32] value.
I32Slice(I32Slice<'a>)
An [i32] slice.
I64(I64)
Single [i64] value.
I64Slice(I64Slice<'a>)
An [i64] slice.
String(String)
A String.
StringSlice(StringSlice)
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.
ColorSlice(ColorSlice<'a>)
A flat [f32] slice of colors (len % 3 == 0).
Point(Point<'a>)
Point, given as three [f32] values.
PointSlice(PointSlice<'a>)
A flat [f32] slice of points (len % 3 == 0).
Vector(Vector<'a>)
Vector, given as three [f32] values.
VectorSlice(VectorSlice<'a>)
A flat [f32] slice of vectors (len % 3 == 0).
Normal(Normal<'a>)
Normal vector, given as three [f32] values.
NormalSlice(NormalSlice<'a>)
A flat [f32] slice of normals (len % 3 == 0).
MatrixF32(MatrixF32<'a>)
Row-major, 4×4 transformation matrix, given as 16 [f32] values.
MatrixF32Slice(MatrixF32Slice<'a>)
A flat [f32] slice of matrices (len % 16 == 0).
MatrixF64(MatrixF64<'a>)
Row-major, 4×4 transformation matrix, given as 16 [f64] values.
MatrixF64Slice(MatrixF64Slice<'a>)
A flat [f64] slice of matrices (len % 16 == 0).
Point4F32Slice(Point4F32Slice<'a>)
A slice of 4-component f32 points (xyzw).
Wire-side: a flat NSITypeFloat slice of 4 * N floats — the
renderer groups them by attribute semantics. Use the
point4_f32_slice! macro to keep
&[[f32; 4]] ergonomics in Rust while the FFI sees the flat
layout.
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,
}
// Must use heap allocation for stable address
let payload = Box::new(Payload { some_data: 42 });
ctx.set_attribute(
"driver",
&[
nsi::string!("drivername", "custom_driver"),
// Payload gets sent as raw pointer through
// the FFI boundary. The Box ensures stable address.
nsi::reference!("payload", &payload),
],
);
// We need to explicitly call drop here as
// ctx's lifetime is pegged to that of payload.
drop(ctx);ReferenceSlice(ReferenceSlice<'b>)
A Reference slice.
Callback(Callback<'b>)
A callback.