Struct CapeArrayObjectVec

Source
pub struct CapeArrayObjectVec<ElementImpl, ElementInterface> {
    vec: Vec<ElementImpl>,
    interface_vec: Vec<ElementInterface>,
    interface_ptr_vec: Vec<*mut ElementInterface>,
}
Expand description

Base implementation for CapeArrayStringVec and CapeArrayValueVec

Fields§

§vec: Vec<ElementImpl>§interface_vec: Vec<ElementInterface>§interface_ptr_vec: Vec<*mut ElementInterface>

Implementations§

Source§

impl<ElementImpl, ElementInterface> CapeArrayObjectVec<ElementImpl, ElementInterface>

Source

pub fn new() -> Self

Create a new CapeArrayObjectVec

Creates a new CapeArrayObjectVec with an empty array.

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

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

Return a vector

Returns a reference to the vector of ElementImpl.

§Example
use cobia;
use cobia::prelude::*;
let arr = cobia::CapeArrayStringVec::from_slice(&["idealGasEnthalpy", "idealGasEntropy"]);
assert_eq!(arr.as_vec()[0].as_string(), "idealGasEnthalpy".to_string());
Source

pub fn size(&self) -> usize

Return size

Returns the size of the vector.

§Example
use cobia;
use cobia::prelude::*;
let arr = cobia::CapeArrayStringVec::from_slice(&["idealGasEnthalpy", "idealGasEntropy"]);
assert_eq!(arr.size(), 2);
Source

pub fn is_empty(&self) -> bool

Check if empty

Returns true if the vector is empty.

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

pub fn iter(&self) -> CapeArrayObjectRefIterator<'_, ElementImpl>

Return an iterator for the array.

§Examples
use cobia::*;

fn test_iter(a: &CapeArrayStringIn) {
	let mut iter = a.iter();
	assert_eq!(cobia::CapeStringConstNoCase::from_string("IDEALGASENTHALPY"),iter.next().unwrap());
	assert_eq!(cobia::CapeStringConstNoCase::from_string("idealgasentropy"),iter.next().unwrap());
	assert!(!iter.next().is_some());
}
 
let arr = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy", "idealGasEntropy"]);
test_iter(&CapeArrayStringInFromProvider::from(&arr).as_cape_array_string_in());
Source§

impl CapeArrayObjectVec<CapeStringImpl, _ICapeString>

Source

const CAPE_ARRAY_STRING_VTABLE: ICapeArrayString_VTable

interface v-table

Source

pub fn from_slice<T: AsRef<str>>(array: &[T]) -> CapeArrayStringVec

Initialize from string vector

Creates a new CapeArrayStringVec from a vector of array of strings.

§Arguments
  • array - A vector or array or slice of strings or string slices to be converted to a CapeArrayStringVec
§Examples
use cobia;
let arr = cobia::CapeArrayStringVec::from_slice(&["idealGasEnthalpy", "idealGasEntropy"]);
assert_eq!(arr.as_string_vec(), vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
Source

pub fn as_string_vec(&self) -> Vec<String>

Return a string vector

Returns a vector of strings from the CapeArrayStringVec.

Note that this operation comes with an overhead of string conversion.

§Examples
use cobia;
let arr = cobia::CapeArrayStringVec::from_slice(&["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
let strvec = arr.as_string_vec();
assert_eq!(strvec, vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
Source

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

Resize

Change the size of the vector.

§Arguments
  • size - The new size of the vector
§Example
use cobia;
use cobia::prelude::*;
let mut arr = cobia::CapeArrayStringVec::from_slice(&["idealGasEnthalpy", "idealGasEntropy"]);
arr.resize(3);
assert_eq!(arr.size(), 3);
Source

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

Set the content of the string array from any object that implements CapeArrayStringProviderIn.

§Arguments
  • array - An object that implements CapeArrayStringProviderIn
§Example
use cobia;

let mut arr = cobia::CapeArrayStringVec::new();
let arr1 = cobia::CapeArrayStringVec::from_slice(&vec!["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]);
arr.set(&arr1);
assert_eq!(arr.as_string_vec(), ["idealGasEnthalpy".to_string(), "idealGasEntropy".to_string()]); //the values have been stored on the object that implements ICapeArrayString
Source

extern "C" fn get( me: *mut c_void, data: *mut *mut *mut ICapeString, size: *mut CapeSize, )

interface member

Source

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

interface member

Source§

impl CapeArrayObjectVec<CapeValueImpl, ICapeValue>

Source

const CAPE_ARRAY_VALUE_VTABLE: ICapeArrayValue_VTable

interface v-table

Source

pub fn from_slice(array: &[CapeValueContent]) -> CapeArrayValueVec

Initialize from CapeValueContent slice

Creates a new CapeArrayValueVec from or slice of CapeValueContent; note that the values will be cloned.

§Arguments
  • array - A slice of values to converted to a CapeArrayValueVec
§Examples
use cobia;
let arr = cobia::CapeArrayValueVec::from_slice(&[cobia::CapeValueContent::Real(2.4),cobia::CapeValueContent::Boolean(true)]);
assert_eq!(arr.as_value_vec(), vec![cobia::CapeValueContent::Real(2.4),cobia::CapeValueContent::Boolean(true)]);
Source

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

Return a value vector

Returns a vector of values from the CapeArrayValueVec.

§Examples
use cobia;
let arr = cobia::CapeArrayValueVec::from_slice(&[cobia::CapeValueContent::Empty,cobia::CapeValueContent::Integer(4)]);
let valvec = arr.as_value_vec();
assert_eq!(valvec, vec![cobia::CapeValueContent::Empty,cobia::CapeValueContent::Integer(4)]);
Source

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

Resize

Change the size of the vector.

§Arguments
  • size - The new size of the vector
§Example
use cobia;
use cobia::prelude::*;
let mut arr = cobia::CapeArrayValueVec::from_slice(&[cobia::CapeValueContent::Empty,cobia::CapeValueContent::Integer(4)]);
arr.resize(3);
assert_eq!(arr.size(), 3);
Source

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

Set the content of the value array from any object that implements CapeArrayValueProviderIn.

§Arguments
  • array - An object that implements CapeArrayValueProviderIn
§Example
use cobia;
let mut arr = cobia::CapeArrayValueVec::new();
let mut arr1 = cobia::CapeArrayValueVec::from_slice(&[cobia::CapeValueContent::Empty,cobia::CapeValueContent::Integer(4)]);
arr.set(&arr1);
assert_eq!(arr.as_value_vec(), vec![cobia::CapeValueContent::Empty,cobia::CapeValueContent::Integer(4)]);
Source

extern "C" fn get( me: *mut c_void, data: *mut *mut *mut ICapeValue, size: *mut CapeSize, )

interface member

Source

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

interface member

Trait Implementations§

Source§

impl<ElementImpl: Clone, ElementInterface: Clone> Clone for CapeArrayObjectVec<ElementImpl, ElementInterface>

Source§

fn clone(&self) -> CapeArrayObjectVec<ElementImpl, ElementInterface>

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<ElementImpl, ElementInterface> Index<usize> for CapeArrayObjectVec<ElementImpl, ElementInterface>

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;
let arr = cobia::CapeArrayStringVec::from_slice(&["idealGasEnthalpy", "idealGasEntropy"]);
assert_eq!(arr[0].as_string(), "idealGasEnthalpy");
Source§

type Output = ElementImpl

The returned type after indexing.
Source§

impl<ElementImpl, ElementInterface> IndexMut<usize> for CapeArrayObjectVec<ElementImpl, ElementInterface>

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;
let mut arr = cobia::CapeArrayStringVec::from_slice(&["idealGasEnthalpy", "idealGasEntropy"]);
arr[0].set_string("idealGasHeatCapacity");
assert_eq!(arr.as_string_vec(), vec!["idealGasHeatCapacity".to_string(), "idealGasEntropy".to_string()]);

Auto Trait Implementations§

§

impl<ElementImpl, ElementInterface> Freeze for CapeArrayObjectVec<ElementImpl, ElementInterface>

§

impl<ElementImpl, ElementInterface> RefUnwindSafe for CapeArrayObjectVec<ElementImpl, ElementInterface>
where ElementImpl: RefUnwindSafe, ElementInterface: RefUnwindSafe,

§

impl<ElementImpl, ElementInterface> !Send for CapeArrayObjectVec<ElementImpl, ElementInterface>

§

impl<ElementImpl, ElementInterface> !Sync for CapeArrayObjectVec<ElementImpl, ElementInterface>

§

impl<ElementImpl, ElementInterface> Unpin for CapeArrayObjectVec<ElementImpl, ElementInterface>
where ElementImpl: Unpin, ElementInterface: Unpin,

§

impl<ElementImpl, ElementInterface> UnwindSafe for CapeArrayObjectVec<ElementImpl, ElementInterface>
where ElementImpl: UnwindSafe, ElementInterface: UnwindSafe + RefUnwindSafe,

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.