pub struct CapeArrayStringIn<'a> {
data: *mut *mut ICapeString,
size: CapeSize,
interface: &'a *mut ICapeArrayString,
_lifetime: PhantomData<&'a ()>,
}Expand description
CapeArrayStringIn wraps an ICapeArrayString interface pointer in a read-only manner
Given a reference to an ICapeArrayString 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 ICapeArrayString input arguments.
A NULL interface pointer is treated as an empty array.
§Examples
use cobia::*;
fn test_content(a: &CapeArrayStringIn) {
assert_eq!(a.as_string_vec(), vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
}
let arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
test_content(&CapeArrayStringInFromProvider::from(&arr).as_cape_array_string_in());Fields§
§data: *mut *mut ICapeString§size: CapeSize§interface: &'a *mut ICapeArrayString§_lifetime: PhantomData<&'a ()>Implementations§
Source§impl<'a> CapeArrayStringIn<'a>
impl<'a> CapeArrayStringIn<'a>
Sourcepub fn new(interface: &'a *mut ICapeArrayString) -> CapeArrayStringIn<'a>
pub fn new(interface: &'a *mut ICapeArrayString) -> CapeArrayStringIn<'a>
Create a new CapeStringIn from an ICapeArrayString interface pointer.
§Arguments
interface- A pointer to an ICapeArrayString interface
§Examples
use cobia::*;
use cobia::prelude::*;
let arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
let i_cape_array_string=arr.as_cape_array_string_in();
let mut i_cape_array_string_ptr=(&i_cape_array_string as *const C::ICapeArrayString).cast_mut(); //normally a pointer to the interface is received
let sa = cobia::CapeArrayStringIn::new(&mut i_cape_array_string_ptr); //CapeArrayStringIn from *mut C::ICapeArrayString
assert_eq!(sa.as_string_vec(), vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);Sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Return the size of the vector
§Examples
use cobia::*;
fn test_size(a: &CapeArrayStringIn) {
assert_eq!(a.size(), 2);
}
let arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
test_size(&CapeArrayStringInFromProvider::from(&arr).as_cape_array_string_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: &CapeArrayStringIn) {
assert!(a.is_empty());
}
let arr = cobia::CapeArrayStringVec::new();
test_empty(&CapeArrayStringInFromProvider::from(&arr).as_cape_array_string_in());Sourcepub fn as_string_vec(&self) -> Vec<String>
pub fn as_string_vec(&self) -> Vec<String>
Return the content of the string array as a string vector.
§Examples
use cobia::*;
fn test_content(a: &CapeArrayStringIn) {
assert_eq!(a.as_string_vec(), vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
}
let arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
test_content(&CapeArrayStringInFromProvider::from(&arr).as_cape_array_string_in());Sourcepub fn at(&self, index: usize) -> Result<CapeStringIn<'a>, COBIAError>
pub fn at(&self, index: usize) -> Result<CapeStringIn<'a>, COBIAError>
Get an element
§Arguments
index- The index of the element to get
Note that neither Index and IndexMut is provided for CapeArrayStringIn, because these interfaces yield a reference to the element, whereas the elements of CapeArrayStringIn are represented by an interface, which is conveniently wrapped into CapeStringIn.
Note that the life time of the CapeStringIn is tied to the life time of the CapeArrayStringIn.
§Examples
use cobia::*;
fn test_element(a: &CapeArrayStringIn) {
assert_eq!(a.at(1).unwrap().to_string(), "idealGasEntropy".to_string());
}
let arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
test_element(&CapeArrayStringInFromProvider::from(&arr).as_cape_array_string_in());Source§impl<'a> CapeArrayStringIn<'a>
impl<'a> CapeArrayStringIn<'a>
Sourcepub fn iter(&self) -> CapeArrayStringInIterator<'_> ⓘ
pub fn iter(&self) -> CapeArrayStringInIterator<'_> ⓘ
Return an iterator over the string array.
§Examples
use cobia::*;
fn test_iter(a: &CapeArrayStringIn) {
let mut iter = a.iter();
assert_eq!(iter.next().unwrap().to_string(), "idealGasEnthalpy".to_string());
assert_eq!(iter.next().unwrap().to_string(), "idealGasEntropy".to_string());
assert!(!iter.next().is_some());
}
let arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
test_iter(&CapeArrayStringInFromProvider::from(&arr).as_cape_array_string_in());Trait Implementations§
Source§impl<'a> CapeArrayStringProviderIn for CapeArrayStringIn<'a>
impl<'a> CapeArrayStringProviderIn for CapeArrayStringIn<'a>
Source§fn as_cape_array_string_in(&self) -> ICapeArrayString
fn as_cape_array_string_in(&self) -> ICapeArrayString
Source§impl<'a> Display for CapeArrayStringIn<'a>
impl<'a> Display for CapeArrayStringIn<'a>
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Display the content of the string array as a string vector.
§Examples
use cobia::*;
fn test_format(a: &CapeArrayStringIn) {
assert_eq!(format!("{}", a), "[\"idealGasEnthalpy\", \"idealGasEntropy\"]");
}
let arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
test_format(&CapeArrayStringInFromProvider::from(&arr).as_cape_array_string_in());