RustyDataContainer

Struct RustyDataContainer 

Source
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

Source

pub fn from_slice<T: ConversionType>(slice: &[T]) -> Self

Create a new non-owning and non-mutable container from a given slice.

Source

pub fn from_slice_mut<T: ConversionType>(slice: &mut [T]) -> Self

Create a new non-owning but mutable container from a given slice.

Source

pub fn to_box(self) -> Box<RustyDataContainer>

Source

pub unsafe fn to_vec<T: ConversionType>(self) -> Vec<T>

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Drop for RustyDataContainer

Source§

fn drop(&mut self)

Destroy a data container. If the container owns the data the corresponding memory is also deallocated.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.