Struct CapeArraySlice

Source
pub struct CapeArraySlice<'a, Element: Copy + Clone> {
    slice: &'a [Element],
}
Expand description

Slice based implementation of ICapeArray

Base class for several slice based ICapeArray implementations.

Any ICapeArray (e.g. ICapeArrayReal) is passed as data container between CAPE-OPEN functions. It is up to the caller to provide the interface, and its implementation. This class provides a default impementation, that uses a reference to the slice its data

These data types can only be used as input argument, not as output argument, as the reference to the slice is non mutable.

§Examples

use cobia::*;

fn test_content(a: &CapeArrayRealIn) {
	assert_eq!(a.as_slice(), &[2.5,4.5]);
}
 
let arr = cobia::CapeArrayRealSlice::new(&[2.5,4.5]);
test_content(&CapeArrayRealInFromProvider::from(&arr).as_cape_array_real_in());

Fields§

§slice: &'a [Element]

Implementations§

Source§

impl<'a, Element: Copy + Clone> CapeArraySlice<'a, Element>

Source

pub fn new(slice: &'a [Element]) -> Self

New from slice

Creates a new CapeArraySlice from a slice.

§Arguments
  • slice - A vector or slice or slice of values to be used as CapeArraySlice - values are referenced
§Examples
use cobia;
use cobia::prelude::*;
let arr = cobia::CapeArrayRealSlice::new(&[2.5,4.5]);
assert_eq!(arr.as_slice(), &vec![2.5,4.5]);
Source

pub fn as_slice(&self) -> &'a [Element]

Return a slice

Returns a reference to the slice of type T.

§Example
use cobia;
use cobia::prelude::*;
let arr = cobia::CapeArrayRealSlice::new(&[2.5,4.5]);
assert_eq!(arr.as_slice(), &vec![2.5,4.5]);
Source

pub fn size(&self) -> usize

Get size

Returns the size of the slice.

§Examples
use cobia;
use cobia::prelude::*;
let arr = cobia::CapeArrayRealSlice::new(&[2.5,4.5]);
assert_eq!(arr.size(), 2);
Source§

impl<'a> CapeArraySlice<'a, f64>

Source

const VTABLE: ICapeArrayReal_VTable

Interface v-table

Source

extern "C" fn get( me: *mut c_void, data: *mut *mut CapeReal, size: *mut CapeSize, )

Interface member function

Source

extern "C" fn setsize( _: *mut c_void, _: CapeSize, _: *mut *mut CapeReal, ) -> CapeResult

Interface member function

Source§

impl<'a> CapeArraySlice<'a, i32>

Source

const VTABLE: ICapeArrayInteger_VTable

Interface v-table

Source

extern "C" fn get( me: *mut c_void, data: *mut *mut CapeInteger, size: *mut CapeSize, )

Interface member function

Source

extern "C" fn setsize( _: *mut c_void, _: CapeSize, _: *mut *mut CapeInteger, ) -> CapeResult

Interface member function

Source§

impl<'a> CapeArraySlice<'a, u8>

Source

const VTABLE: ICapeArrayByte_VTable

Interface v-table

Source

extern "C" fn get( me: *mut c_void, data: *mut *mut CapeByte, size: *mut CapeSize, )

Interface member function

Source

extern "C" fn setsize( _: *mut c_void, _: CapeSize, _: *mut *mut CapeByte, ) -> CapeResult

Interface member function

Source§

impl<'a> CapeArraySlice<'a, u32>

Source

const VTABLE: ICapeArrayBoolean_VTable

Interface v-table

Source

extern "C" fn get( me: *mut c_void, data: *mut *mut CapeBoolean, size: *mut CapeSize, )

Interface member function

Source

extern "C" fn setsize( _: *mut c_void, _: CapeSize, _: *mut *mut CapeBoolean, ) -> CapeResult

Interface member function

Source§

impl<'a> CapeArraySlice<'a, CapeEnumeration>

Source

const VTABLE_RAW: ICapeArrayEnumeration_VTable

Interface v-table

Source

extern "C" fn get_raw( me: *mut c_void, data: *mut *mut CapeEnumeration, size: *mut CapeSize, )

Interface member function

Source

extern "C" fn setsize_raw( _: *mut c_void, _: CapeSize, _: *mut *mut CapeEnumeration, ) -> CapeResult

Interface member function

Trait Implementations§

Source§

impl<'a, Element: Copy + Clone> AsRef<[Element]> for CapeArraySlice<'a, Element>

Source§

fn as_ref(&self) -> &[Element]

Return a reference to the slice

Returns a reference to the slice [Element].

Auto Trait Implementations§

§

impl<'a, Element> Freeze for CapeArraySlice<'a, Element>

§

impl<'a, Element> RefUnwindSafe for CapeArraySlice<'a, Element>
where Element: RefUnwindSafe,

§

impl<'a, Element> Send for CapeArraySlice<'a, Element>
where Element: Sync,

§

impl<'a, Element> Sync for CapeArraySlice<'a, Element>
where Element: Sync,

§

impl<'a, Element> Unpin for CapeArraySlice<'a, Element>

§

impl<'a, Element> UnwindSafe for CapeArraySlice<'a, Element>
where Element: RefUnwindSafe,

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.