Struct CapeArrayStringIn

Source
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>

Source

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()]);
Source

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());
Source

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());
Source

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());
Source

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>

Source

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>

Source§

fn as_cape_array_string_in(&self) -> ICapeArrayString

Convert to ICapeArrayString
Source§

impl<'a> Display for CapeArrayStringIn<'a>

Source§

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());

Auto Trait Implementations§

§

impl<'a> Freeze for CapeArrayStringIn<'a>

§

impl<'a> RefUnwindSafe for CapeArrayStringIn<'a>

§

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

§

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

§

impl<'a> Unpin for CapeArrayStringIn<'a>

§

impl<'a> UnwindSafe for CapeArrayStringIn<'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.