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>
impl<'a> CapeArrayValueIn<'a>
Sourcepub fn new(interface: &'a *mut ICapeArrayValue) -> CapeArrayValueIn<'a>
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]);Sourcepub fn size(&self) -> usize
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());Sourcepub fn is_empty(&self) -> bool
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());Sourcepub fn at(&self, index: usize) -> Result<CapeValueIn<'a>, COBIAError>
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());Sourcepub fn as_value_vec(&self) -> Result<Vec<CapeValueContent>, COBIAError>
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>
impl<'a> CapeArrayValueIn<'a>
Sourcepub fn iter(&self) -> CapeArrayValueInIterator<'_> ⓘ
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>
impl<'a> CapeArrayValueProviderIn for CapeArrayValueIn<'a>
Source§fn as_cape_array_value_in(&self) -> ICapeArrayValue
fn as_cape_array_value_in(&self) -> ICapeArrayValue
Source§impl<'a> Display for CapeArrayValueIn<'a>
impl<'a> Display for CapeArrayValueIn<'a>
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
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());