Struct CapeArrayValueIn

Source
pub struct CapeArrayValueIn<'a> {
    data: *mut *mut ICapeValue,
    size: CapeSize,
    interface: &'a *mut ICapeArrayValue,
    _lifetime: PhantomData<&'a ()>,
}
Expand description

CapeArrayValueIn wraps an ICapeArrayValue interface pointer in a read-only manner

Given a reference to an ICapeArrayValue interface pointer, this allows getting, but not setting the elements.

This interface is typically used as arguments to rust methods on traits that are generated from CAPE-OPEN interfaces that have ICapeArrayValue input arguments.

A NULL interface pointer is treated as an empty array.

§Examples

use cobia::*;

fn test_content(a: &CapeArrayValueIn) {
	assert_eq!(a.as_value_vec().unwrap(), vec![cobia::CapeValueContent::Boolean(true),cobia::CapeValueContent::Real(1.2),cobia::CapeValueContent::Empty]);
}
 
let arr = cobia::CapeArrayValueVec::from_slice(&[cobia::CapeValueContent::Boolean(true),cobia::CapeValueContent::Real(1.2),cobia::CapeValueContent::Empty]);
test_content(&CapeArrayValueInFromProvider::from(&arr).as_cape_array_value_in());

Fields§

§data: *mut *mut ICapeValue§size: CapeSize§interface: &'a *mut ICapeArrayValue§_lifetime: PhantomData<&'a ()>

Implementations§

Source§

impl<'a> CapeArrayValueIn<'a>

Source

pub fn new(interface: &'a *mut ICapeArrayValue) -> CapeArrayValueIn<'a>

Create a new CapeValueIn from an ICapeArrayValue interface pointer.

§Arguments
  • interface - A pointer to an ICapeArrayValue interface
§Examples
use cobia::*;
use cobia::prelude::*;
let arr = cobia::CapeArrayValueVec::from_slice(&[cobia::CapeValueContent::Boolean(true),cobia::CapeValueContent::Real(1.2),cobia::CapeValueContent::Empty]);
let i_cape_array_value=arr.as_cape_array_value_in();
let mut i_cape_array_value_ptr=(&i_cape_array_value as *const C::ICapeArrayValue).cast_mut(); //normally a pointer to the interface is received
let va = cobia::CapeArrayValueIn::new(&mut i_cape_array_value_ptr); //CapeArrayValueIn from *mut C::ICapeArrayValue
assert_eq!(va.as_value_vec().unwrap(), vec![cobia::CapeValueContent::Boolean(true),cobia::CapeValueContent::Real(1.2),cobia::CapeValueContent::Empty]);
Source

pub fn size(&self) -> usize

Return the size of the array

§Examples
use cobia::*;

fn test_size(a: &CapeArrayValueIn) {
	assert_eq!(a.size(), 3);
}
 
let arr = cobia::CapeArrayValueVec::from_slice(&[cobia::CapeValueContent::Boolean(true),cobia::CapeValueContent::Real(1.2),cobia::CapeValueContent::Empty]);
test_size(&CapeArrayValueInFromProvider::from(&arr).as_cape_array_value_in());
Source

pub fn is_empty(&self) -> bool

Check if the array is empty

§Examples
use cobia::*;

fn test_empty(a: &CapeArrayValueIn) {
	assert!(a.is_empty());
}
 
let arr = cobia::CapeArrayValueVec::new();
test_empty(&CapeArrayValueInFromProvider::from(&arr).as_cape_array_value_in());
Source

pub fn at(&self, index: usize) -> Result<CapeValueIn<'a>, COBIAError>

Get an element

§Arguments
  • index - The index of the element to get

Note that neither Index and IndexMut is provided for CapeArrayValueIn, because these interfaces yield a reference to the element, whereas the elements of CapeArrayValueIn are represented by an interface, which is conveniently wrapped into CapeValueIn.

Note that the life time of the CapeValueIn is tied to the life time of the CapeArrayValueIn.

§Examples
use cobia::*;

fn test_size(a: &CapeArrayValueIn) {
	assert_eq!(a.at(1).unwrap().get_boolean().unwrap(), true);
}
 
let arr = cobia::CapeArrayValueVec::from_slice(&[cobia::CapeValueContent::Real(2.4),cobia::CapeValueContent::Boolean(true)]);
test_size(&CapeArrayValueInFromProvider::from(&arr).as_cape_array_value_in());
Source

pub fn as_value_vec(&self) -> Result<Vec<CapeValueContent>, COBIAError>

Return the content of the value array as a vector of CapeValueContent

§Examples
use cobia::*;

fn test_content(a: &CapeArrayValueIn) {
	assert_eq!(a.as_value_vec().unwrap(), vec![cobia::CapeValueContent::Real(2.4),cobia::CapeValueContent::Boolean(true)]);
}
 
let arr = cobia::CapeArrayValueVec::from_slice(&[cobia::CapeValueContent::Real(2.4),cobia::CapeValueContent::Boolean(true)]);
test_content(&CapeArrayValueInFromProvider::from(&arr).as_cape_array_value_in());
Source§

impl<'a> CapeArrayValueIn<'a>

Source

pub fn iter(&self) -> CapeArrayValueInIterator<'_>

Return an iterator over the value array.

§Examples
use cobia::*;

fn test_iter(a: &CapeArrayValueIn) {
	let mut iter = a.iter();
	assert_eq!(iter.next().unwrap().get_integer().unwrap(), 4);
	assert_eq!(iter.next().unwrap().get_boolean().unwrap(), true);
	assert!(!iter.next().is_some());
}
 
let arr = cobia::CapeArrayValueVec::from_slice(&[cobia::CapeValueContent::Integer(4),cobia::CapeValueContent::Boolean(true)]);
test_iter(&CapeArrayValueInFromProvider::from(&arr).as_cape_array_value_in());

Trait Implementations§

Source§

impl<'a> CapeArrayValueProviderIn for CapeArrayValueIn<'a>

Source§

fn as_cape_array_value_in(&self) -> ICapeArrayValue

Convert to ICapeArrayValue
Source§

impl<'a> Display for CapeArrayValueIn<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Display the content of the value array as a vector.

§Examples
use cobia::*;

fn test_format(a: &CapeArrayValueIn) {
	assert_eq!(format!("{}", a), "[4, true, <empty>, \"H2O\"]");
}
 
let arr = cobia::CapeArrayValueVec::from_slice(&[cobia::CapeValueContent::Integer(4),cobia::CapeValueContent::Boolean(true),cobia::CapeValueContent::Empty,cobia::CapeValueContent::String("H2O".to_string())]);
test_format(&CapeArrayValueInFromProvider::from(&arr).as_cape_array_value_in());

Auto Trait Implementations§

§

impl<'a> Freeze for CapeArrayValueIn<'a>

§

impl<'a> RefUnwindSafe for CapeArrayValueIn<'a>

§

impl<'a> !Send for CapeArrayValueIn<'a>

§

impl<'a> !Sync for CapeArrayValueIn<'a>

§

impl<'a> Unpin for CapeArrayValueIn<'a>

§

impl<'a> UnwindSafe for CapeArrayValueIn<'a>

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.