Struct CapeArrayVec

Source
pub struct CapeArrayVec<Element: Copy + Clone, InterfaceType> {
    vec: Vec<Element>,
    interface_type: PhantomData<InterfaceType>,
}
Expand description

Vector based implementation of ICapeArray

Base class for several vector 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 std::vec::Vec as the data container.

§Examples

use cobia::*;

fn set_content(arr: &mut CapeArrayRealOut) {
	arr.put_array(&[4.5,6.5]).unwrap();
}
 
let mut arr = cobia::CapeArrayRealVec::from_slice(&[4.5,6.5]);
set_content(&mut CapeArrayRealOutFromProvider::from(&mut arr).as_cape_array_real_out());
assert_eq!(arr.as_vec(), &vec![4.5,6.5]);

Fields§

§vec: Vec<Element>§interface_type: PhantomData<InterfaceType>

Implementations§

Source§

impl<Element: Copy + Clone, InterfaceType> CapeArrayVec<Element, InterfaceType>

Source

pub fn new() -> Self

Create a new CapeArrayVec

Creates a new empty CapeArrayVec

§Examples
use cobia;
use cobia::prelude::*;
let arr = cobia::CapeArrayRealVec::new();
assert_eq!(arr.as_vec().len(), 0);
Source

pub fn as_vec(&self) -> &Vec<Element>

Return a vector

Returns a reference to the vector of type T.

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

pub fn as_mut_vec(&mut self) -> &mut Vec<Element>

Return a mutable vector

Returns a mutable reference to the vector of type T.

§Example
use cobia;
use cobia::prelude::*;
let mut arr = cobia::CapeArrayRealVec::from_vec(vec![2.5,4.5]);
arr.as_mut_vec().push(6.5);
assert_eq!(arr.as_vec(), &vec![2.5,4.5,6.5]);
Source

pub fn size(&self) -> usize

Get size

Returns the size of the array.

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

pub fn from_slice(slice: &[Element]) -> Self

Initialize from slice

Creates a new CapeArrayVec from a slice.

§Arguments
  • slice - A vector or array or slice of values to be converted to a CapeArrayVec - values are copied
§Examples
use cobia;
use cobia::prelude::*;
let arr = cobia::CapeArrayRealVec::from_slice(&[2.5,4.5]);
assert_eq!(arr.as_vec(), &vec![2.5,4.5]);
Source

pub fn is_empty(&self) -> bool

Check if empty

Returns true if the array is empty.

§Examples
use cobia;
use cobia::prelude::*;
let arr = cobia::CapeArrayRealVec::new();
assert!(arr.is_empty());
Source

pub fn from_vec(vec: Vec<Element>) -> Self

Initialize from vector

Creates a new CapeArrayVec from a vector, taking ownwership of the data

§Arguments
  • vec - A vector slice of values to be converted to a CapeArrayVec
§Examples
use cobia;
use cobia::prelude::*;
let arr = cobia::CapeArrayRealVec::from_slice(&[2.5,4.5]);
assert_eq!(arr.as_vec(), &vec![2.5,4.5]);
Source§

impl CapeArrayVec<f64, ICapeArrayReal>

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

pub fn resize(&mut self, size: usize)

Resize

Resize the array to the given size. If the size is larger than the current size, the new elements are set to CapeReal::NAN.

§Arguments
  • size - The new size of the array
§Examples
use cobia;
use cobia::prelude::*;
let mut arr = cobia::CapeArrayRealVec::from_slice(&[2.5,4.5]);
arr.resize(4);
assert_eq!(arr.size(), 4);
assert!(arr[2].is_nan());
Source

pub fn set<T: CapeArrayRealProviderIn>( &mut self, array: &T, ) -> Result<(), COBIAError>

Set the content of the real array from any object that implements CapeArrayRealProviderIn.

§Arguments
  • array - An object that implements CapeArrayRealProviderIn
§Example
use cobia;
let mut arr = cobia::CapeArrayRealVec::new();
let arr1 = cobia::CapeArrayRealVec::from_slice(&[2.5,4.5]);
arr.set(&arr1);
assert_eq!(arr.as_vec(), &vec![2.5,4.5]);
Source

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

Interface member function

Source§

impl CapeArrayVec<i32, ICapeArrayInteger>

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( me: *mut c_void, size: CapeSize, data: *mut *mut CapeInteger, ) -> CapeResult

Interface member function

Source

pub fn resize(&mut self, size: usize)

Resize

Resize the array to the given size. If the size is larger than the current size, the new elements are set to 0.

§Arguments
  • size - The new size of the array
§Examples
use cobia;
use cobia::prelude::*;
let mut arr = cobia::CapeArrayIntegerVec::from_slice(&[2,4]);
arr.resize(4);
assert_eq!(arr.as_vec(), &vec![2 as cobia::CapeInteger,4 as cobia::CapeInteger,0 as cobia::CapeInteger,0 as cobia::CapeInteger]);
Source

pub fn set<T: CapeArrayIntegerProviderIn>( &mut self, array: &T, ) -> Result<(), COBIAError>

Set the content of the integer array from any object that implements CapeArrayIntegerProviderIn.

§Arguments
  • array - An object that implements CapeArrayIntegerProviderIn
§Example
use cobia;
let mut arr = cobia::CapeArrayIntegerVec::new();
let arr1 = cobia::CapeArrayIntegerVec::from_slice(&[8,9,7]);
arr.set(&arr1);
assert_eq!(arr.as_vec(), &vec![8,9,7]);
Source§

impl CapeArrayVec<u8, ICapeArrayByte>

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( me: *mut c_void, size: CapeSize, data: *mut *mut CapeByte, ) -> CapeResult

Interface member function

Source

pub fn resize(&mut self, size: usize)

Resize

Resize the array to the given size. If the size is larger than the current size, the new elements are set to 0.

§Arguments
  • size - The new size of the array
§Examples
use cobia;
use cobia::prelude::*;
let mut arr = cobia::CapeArrayByteVec::from_slice(&[2u8,4u8]);
arr.resize(4);
assert_eq!(arr.as_vec(), &vec![2u8,4u8,0,0]);
Source

pub fn set<T: CapeArrayByteProviderIn>( &mut self, array: &T, ) -> Result<(), COBIAError>

Set the content of the byte array from any object that implements CapeArrayByteProviderIn.

§Arguments
  • array - An object that implements CapeArrayByteProviderIn
§Example
use cobia;
let mut arr = cobia::CapeArrayByteVec::new();
let arr1 = cobia::CapeArrayByteVec::from_slice(&[8,9,7]);
arr.set(&arr1);
assert_eq!(arr.as_vec(), &vec![8,9,7]);
Source§

impl CapeArrayVec<u32, ICapeArrayBoolean>

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

pub fn resize(&mut self, size: usize)

Resize

Resize the array to the given size. If the size is larger than the current size, the new elements are set to false.

§Arguments
  • size - The new size of the array
§Examples
use cobia;
use cobia::prelude::*;
let mut arr = cobia::CapeArrayBooleanVec::from_bool_slice(&[true,false]);
arr.resize(4);
assert_eq!(arr.as_vec(), &vec![true as cobia::CapeBoolean,false as cobia::CapeBoolean,false as cobia::CapeBoolean,false as cobia::CapeBoolean]);
Source

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

Interface member function

Source

pub fn set<T: CapeArrayBooleanProviderIn>( &mut self, array: &T, ) -> Result<(), COBIAError>

Set the content of the boolean array from any object that implements CapeArrayBooleanProviderIn.

§Arguments
  • array - An object that implements CapeArrayBooleanProviderIn
§Example
use cobia;
let mut arr = cobia::CapeArrayBooleanVec::new();
let arr1 = cobia::CapeArrayBooleanVec::from_slice(&[8,9,7]);
arr.set(&arr1);
assert_eq!(arr.as_vec(), &vec![8,9,7]);
Source§

impl CapeArrayVec<u32, ICapeArrayBoolean>

Source

pub fn from_bool_slice(slice: &[bool]) -> Self

Initialize from bool slice

Creates a new CapeArrayTypeImpl from a bool slice.

§Arguments
  • slice - A vector or array or slice of values to be converted to a CapeArrayTypeImpl - values are copied
§Examples
use cobia::*;
use cobia::prelude::*;
let arr = CapeArrayBooleanVec::from_bool_slice(&[true,false,false]);
assert_eq!(arr.as_vec(), &vec![true as CapeBoolean,false as CapeBoolean,false as CapeBoolean]);
Source§

impl CapeArrayVec<CapeEnumeration, ICapeArrayEnumeration>

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( me: *mut c_void, size: CapeSize, data: *mut *mut CapeEnumeration, ) -> CapeResult

Interface member function

Source§

impl<Element: Copy + Clone> CapeArrayVec<Element, ICapeArrayEnumeration>

Source

pub fn resize(&mut self, size: usize, value: Element)

Resize

Resize the array to the given size. If the size is larger than the current size, the new elements are set specified value.

§Arguments
  • size - The new size of the array
  • value - The value to set the new elements to
§Examples
use cobia;
use cobia::prelude::*;
let mut arr = cobia::CapeArrayEnumerationVec::from_slice(&[cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64]);
arr.resize(4,cobia::CapePMCServiceType::Inproc32);
assert_eq!(arr.as_vec(), &vec![cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64,cobia::CapePMCServiceType::Inproc32,cobia::CapePMCServiceType::Inproc32]);

Trait Implementations§

Source§

impl<Element: Copy + Clone, InterfacType> AsRef<[Element]> for CapeArrayVec<Element, InterfacType>

Source§

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

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<Element: Clone + Copy + Clone, InterfaceType: Clone> Clone for CapeArrayVec<Element, InterfaceType>

Source§

fn clone(&self) -> CapeArrayVec<Element, InterfaceType>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Element: Copy + Clone, InterfacType> Default for CapeArrayVec<Element, InterfacType>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<Element: Copy + Clone, InterfacType> Index<usize> for CapeArrayVec<Element, InterfacType>

Source§

fn index(&self, index: usize) -> &Self::Output

Indexing

Returns a reference to the element at the given index.

§Arguments
  • index - The index of the element to be returned
§Examples
use cobia;
use cobia::prelude::*;
let arr = cobia::CapeArrayRealVec::from_slice(&[10.1,10.2,10.3]);
assert_eq!(arr[1], 10.2);
Source§

type Output = Element

The returned type after indexing.
Source§

impl<Element: Copy + Clone, Interface> IndexMut<usize> for CapeArrayVec<Element, Interface>

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Indexing

Returns a mutable reference to the element at the given index.

§Arguments
  • index - The index of the element to be returned
§Examples
use cobia;
use cobia::prelude::*;
let mut arr = cobia::CapeArrayRealVec::from_slice(&[10.1,10.2,10.3]);
arr[1]=2.2;
assert_eq!(arr[1], 2.2);

Auto Trait Implementations§

§

impl<Element, InterfaceType> Freeze for CapeArrayVec<Element, InterfaceType>

§

impl<Element, InterfaceType> RefUnwindSafe for CapeArrayVec<Element, InterfaceType>
where InterfaceType: RefUnwindSafe, Element: RefUnwindSafe,

§

impl<Element, InterfaceType> Send for CapeArrayVec<Element, InterfaceType>
where InterfaceType: Send, Element: Send,

§

impl<Element, InterfaceType> Sync for CapeArrayVec<Element, InterfaceType>
where InterfaceType: Sync, Element: Sync,

§

impl<Element, InterfaceType> Unpin for CapeArrayVec<Element, InterfaceType>
where InterfaceType: Unpin, Element: Unpin,

§

impl<Element, InterfaceType> UnwindSafe for CapeArrayVec<Element, InterfaceType>
where InterfaceType: UnwindSafe, Element: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.