[][src]Struct nsi::arg::Reference

pub struct Reference<'a> { /* fields omitted */ }

Reference type with lifetime guaratees.

Prefer this over using a raw Pointer as it allows the compiler to check that the data you reference outlives the Context you eventually send it to.

This gets converted to a raw pointer when passed through the FFI boundary.

struct Payload {
    some_data: u32,
}

let ctx = nsi::Context::new(&[]).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::Node::OutputDriver, &[]);
ctx.connect("driver", "", "beauty", "outputdrivers", &[]);
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", Some(&payload)),
    ],
);

// We need to explicitly call drop here as
// ctx's lifetime is pegged to that of payload.
drop(ctx);

Implementations

impl<'a> Reference<'a>[src]

pub fn new(data: Option<&'a dyn Any>) -> Self[src]

Trait Implementations

impl<'a, 'b> From<Reference<'b>> for ArgData<'a, 'b>[src]

impl<'a, 'b> TryInto<Reference<'b>> for ArgData<'a, 'b>[src]

type Error = &'static str

The type returned in the event of a conversion error.

Auto Trait Implementations

impl<'a> RefUnwindSafe for Reference<'a>

impl<'a> !Send for Reference<'a>

impl<'a> !Sync for Reference<'a>

impl<'a> Unpin for Reference<'a>

impl<'a> UnwindSafe for Reference<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.