pub struct RustyDataContainer { /* private fields */ }Expand description
A data container for communication with a C ABI.
The basic task of this container is to provide a C ABI compatible type to store arbitrary data arrays, and to convert them back and forth into corresponding Rust types.
Implementations§
Source§impl RustyDataContainer
impl RustyDataContainer
Sourcepub fn from_slice<T: ConversionType>(slice: &[T]) -> Self
pub fn from_slice<T: ConversionType>(slice: &[T]) -> Self
Create a new non-owning and non-mutable container from a given slice.
Sourcepub fn from_slice_mut<T: ConversionType>(slice: &mut [T]) -> Self
pub fn from_slice_mut<T: ConversionType>(slice: &mut [T]) -> Self
Create a new non-owning but mutable container from a given slice.
pub fn to_box(self) -> Box<RustyDataContainer>
pub unsafe fn to_vec<T: ConversionType>(self) -> Vec<T>
Sourcepub fn leak_mut(
ptr: Option<Box<RustyDataContainer>>,
) -> &'static mut RustyDataContainer
pub fn leak_mut( ptr: Option<Box<RustyDataContainer>>, ) -> &'static mut RustyDataContainer
Get a mutable reference to a RustyDataContainer from a ptr. Ensures that the destructor of the data container is not run.
Sourcepub fn leak(ptr: Option<Box<RustyDataContainer>>) -> &'static RustyDataContainer
pub fn leak(ptr: Option<Box<RustyDataContainer>>) -> &'static RustyDataContainer
Get a reference to a RustyDataContainer from a ptr. Ensures that the destructor of the data container is not run.
Sourcepub fn from_vec<T: ConversionType>(vec: Vec<T>) -> Self
pub fn from_vec<T: ConversionType>(vec: Vec<T>) -> Self
Create a new owning and mutable container from a vector. The vector is consumed by this method.
Sourcepub unsafe fn as_slice<T: ConversionType>(
ptr: Option<Box<RustyDataContainer>>,
) -> &'static [T]
pub unsafe fn as_slice<T: ConversionType>( ptr: Option<Box<RustyDataContainer>>, ) -> &'static [T]
Get a representation of the data as slice.
This method does not take ownership of the container associated with ptr.
Sourcepub unsafe fn as_slice_mut<T: ConversionType>(
ptr: Option<Box<RustyDataContainer>>,
) -> &'static mut [T]
pub unsafe fn as_slice_mut<T: ConversionType>( ptr: Option<Box<RustyDataContainer>>, ) -> &'static mut [T]
Get a representation of the data as mutable slice.
This method does not take ownership of the container associated with ptr.