pub struct LockedPtrs<T, E>where
    T: Pointable<E>,
{ /* private fields */ }
Expand description

This type locks up a Vec<> after creation and gives you a pointer to a vector of pointers: *const *const T.

It locks away the interior std::vec::Vec instances, so that they can’t be accidentally changed while you are messing around with the pointers.

The type T must implement the Pointable trait.

See also LockedMutPtrs for a mutable alternative to this type.

 use synfx_dsp_jit::locked::*;

 struct MyFFIStuff {
     data: LockedPtrs<Vec<i64>, i64>,
 }

 let ffistuff = MyFFIStuff {
     data: LockedPtrs::new(vec![vec![1; 10], vec![2; 30]]),
 };

 // We are guaranteed here, that the pointers here will not be
 // invalidated until MyFFIStuff is dropped!
 let pointers = ffistuff.data.pointers();

 unsafe {
     assert_eq!((*pointers[0]), 1);
     assert_eq!((*pointers[1]), 2);
     assert_eq!((*pointers[0].offset(5)), 1);
     assert_eq!((*pointers[1].offset(5)), 2);
 };

Implementations

Swaps out one element in the locked vector.

Safety

You must not call this function while you still have pointers handed out. These pointers will be invaldiated by this function!

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.