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

This type locks up a Vec<> after creation and gives you a pointer to a vector of mutable pointers: *const *mut 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.

See also LockedPtrs for a mutable alternative to this type.

The type T must implement the MutPointable trait.

 use synfx_dsp_jit::locked::*;

 struct MyFFIStuff {
     data: LockedMutPtrs<Vec<f64>, f64>,
 }

 let ffistuff = MyFFIStuff {
     data: LockedMutPtrs::new(vec![vec![0.0; 10], vec![0.2; 30]]),
 };

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

 unsafe {
     (*pointers[0]) = 10.0;
     (*pointers[0].offset(1)) = 11.0;
     (*pointers[1]) = 20.0;
 };

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.