Struct CapeArrayEnumerationOut

Source
pub struct CapeArrayEnumerationOut<'a, Element: Copy + Clone> {
    interface: &'a mut *mut ICapeArrayEnumeration,
    data: *mut Element,
    size: CapeSize,
}
Expand description

CapeArrayEnumerationOut wraps an ICapeArrayEnumeration interface pointer.

Given an ICapeArrayEnumeration interface pointer, this allows setting and getting the elements.

A NULL pointer is not allowed.

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

This class takes a mutable reference to the interface pointer, as it should be the only class that is in use at a time to change the data behind the interface (as the data pointer is cached)

§Examples

use cobia::*;

fn set_content(a: &mut CapeArrayEnumerationOut<CapePMCServiceType>) {
	a.put_array(&[CapePMCServiceType::Inproc64,CapePMCServiceType::COM64]).unwrap();
}
 
let mut arr = cobia::CapeArrayEnumerationVec::<CapePMCServiceType>::new();
set_content(&mut CapeArrayEnumerationOutFromProvider::from(&mut arr).as_cape_array_enumeration_out());
assert_eq!(arr.as_vec(), &vec![CapePMCServiceType::Inproc64,CapePMCServiceType::COM64]);

Fields§

§interface: &'a mut *mut ICapeArrayEnumeration§data: *mut Element§size: CapeSize

Implementations§

Source§

impl<'a, Element: Copy + Clone> CapeArrayEnumerationOut<'a, Element>

Source

pub fn new(interface: &'a mut *mut ICapeArrayEnumeration) -> Self

Create a new CapeArrayEnumerationOut from an ICapeArrayEnumeration interface pointer.

§Arguments
  • interface - A pointer to an ICapeArrayEnumeration interface
§Examples
use cobia::*;
use cobia::prelude::*;
let mut arr = cobia::CapeArrayEnumerationVec::<cobia::CapePMCServiceType>::from_slice(&[cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64]);
let i_cape_array_enumeration=arr.as_cape_array_enumeration_out();
let mut i_cape_array_enumeration_ptr=(&i_cape_array_enumeration as *const C::ICapeArrayEnumeration).cast_mut(); //normally a pointer to the interface is received
let a = cobia::CapeArrayEnumerationOut::<cobia::CapePMCServiceType>::new(&mut i_cape_array_enumeration_ptr); //CapeArrayEnumerationOut from *mut C::ICapeArrayEnumeration
assert_eq!(a.as_vec(), vec![cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64]);
Source

pub fn size(&self) -> usize

Get the size of the array

§Examples
use cobia::*;

fn test_size(a: &mut CapeArrayEnumerationOut<cobia::CapePMCServiceType>) {
    assert_eq!(a.size(), 2);
}
 
let mut arr = cobia::CapeArrayEnumerationVec::<cobia::CapePMCServiceType>::from_slice(&[cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64]);
test_size(&mut CapeArrayEnumerationOutFromProvider::from(&mut arr).as_cape_array_enumeration_out());
Source

pub fn is_empty(&self) -> bool

Check if the array is empty

§Examples
use cobia::*;

fn test_empty(a: &mut CapeArrayEnumerationOut<cobia::CapePMCServiceType>) {
    assert!(a.is_empty());
}
 
let mut arr = cobia::CapeArrayEnumerationVec::<cobia::CapePMCServiceType>::new();
test_empty(&mut CapeArrayEnumerationOutFromProvider::from(&mut arr).as_cape_array_enumeration_out());
Source

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

Return the content of the array as a vector.

§Examples
use cobia::*;

fn test_content(a: &mut CapeArrayEnumerationOut<cobia::CapePMCServiceType>) {
   assert_eq!(a.as_vec(), vec![cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64]);
}
 
let mut arr = cobia::CapeArrayEnumerationVec::<cobia::CapePMCServiceType>::from_slice(&[cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64]);
test_content(&mut CapeArrayEnumerationOutFromProvider::from(&mut arr).as_cape_array_enumeration_out());
Source

pub fn put_array(&mut self, array: &[Element]) -> Result<(), COBIAError>

Set the content of the array from a slice

§Arguments
  • arr - A slice or array of vector
§Examples
use cobia::*;

fn set_content(a: &mut CapeArrayEnumerationOut<cobia::CapePMCServiceType>) {
   a.put_array(&[cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64]).unwrap();
}
 
let mut arr = cobia::CapeArrayEnumerationVec::<cobia::CapePMCServiceType>::from_slice(&[cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64]);
set_content(&mut CapeArrayEnumerationOutFromProvider::from(&mut arr).as_cape_array_enumeration_out());
assert_eq!(arr.as_vec(), &vec![cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64]); //the values have been stored on the object that implements ICapeArrayEnumeration<cobia::CapePMCServiceType>
Source

pub fn resize(&mut self, size: usize) -> Result<(), COBIAError>

Resize the array

§Arguments
  • size - The new size of the array
§Examples
use cobia::*;

fn resize(a: &mut CapeArrayEnumerationOut<cobia::CapePMCServiceType>) {
   a.resize(4).unwrap();
}
 
let mut arr = cobia::CapeArrayEnumerationVec::<cobia::CapePMCServiceType>::from_slice(&[cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64]);
resize(&mut CapeArrayEnumerationOutFromProvider::from(&mut arr).as_cape_array_enumeration_out());
assert_eq!(arr.size(), 4); 
Source

pub fn as_slice(&self) -> &[Element]

Return the content of the real array as a real slice.

§Examples
use cobia::*;

fn test_content(a: &mut CapeArrayEnumerationOut<cobia::CapePMCServiceType>) {
   assert_eq!(a.as_slice(), &[cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64]);
}
 
let mut arr = cobia::CapeArrayEnumerationVec::<cobia::CapePMCServiceType>::from_vec(vec![cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64]);
test_content(&mut CapeArrayEnumerationOutFromProvider::from(&mut arr).as_cape_array_enumeration_out());
Source

pub fn iter(&self) -> CapeArrayRefIterator<'_, Element>

Return an iterator for the array.

§Examples
use cobia::*;

fn test_iter(a: &mut CapeArrayEnumerationOut<cobia::CapePMCServiceType>) {
   let mut iter = a.iter();
	assert_eq!(iter.next().unwrap(), cobia::CapePMCServiceType::Inproc64);
	assert_eq!(iter.next().unwrap(), cobia::CapePMCServiceType::COM64);
	assert!(!iter.next().is_some());
}
 
let mut arr = cobia::CapeArrayEnumerationVec::<cobia::CapePMCServiceType>::from_vec(vec![cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64]);
test_iter(&mut CapeArrayEnumerationOutFromProvider::from(&mut arr).as_cape_array_enumeration_out());

Trait Implementations§

Source§

impl<'a, Element: Copy + Clone> CapeArrayEnumerationProviderOut for CapeArrayEnumerationOut<'a, Element>

Source§

fn as_cape_array_enumeration_out(&mut self) -> ICapeArrayEnumeration

Convert to ICapeArrayEnumeration
Source§

impl<'a, Element: Copy + Clone + Display> Display for CapeArrayEnumerationOut<'a, Element>

Source§

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

Display the content of the real array as a real vector.

§Examples
use cobia::*;

fn test_format(a: &mut CapeArrayEnumerationOut<cobia::CapePMCServiceType>) {
   assert_eq!(format!("{}", a), "[Inproc64, COM64, Local]");
}
 
let mut arr = cobia::CapeArrayEnumerationVec::<cobia::CapePMCServiceType>::from_vec(vec![cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64,cobia::CapePMCServiceType::Local]);
test_format(&mut CapeArrayEnumerationOutFromProvider::from(&mut arr).as_cape_array_enumeration_out());
Source§

impl<'a, Element: Copy + Clone> Index<usize> for CapeArrayEnumerationOut<'a, Element>

Source§

fn index(&self, index: usize) -> &Self::Output

Indexing

Returns a reference to the string at the given index.

§Arguments
  • index - The index of the string to be returned
§Examples
use cobia::*;

fn test_index(a: &mut CapeArrayEnumerationOut<cobia::CapePMCServiceType>) {
   assert_eq!(a[1], cobia::CapePMCServiceType::COM64);
}
 
let mut arr = cobia::CapeArrayEnumerationVec::<cobia::CapePMCServiceType>::from_vec(vec![cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64]);
test_index(&mut CapeArrayEnumerationOutFromProvider::from(&mut arr).as_cape_array_enumeration_out());
Source§

type Output = Element

The returned type after indexing.
Source§

impl<'a, Element: Copy + Clone> IndexMut<usize> for CapeArrayEnumerationOut<'a, Element>

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Indexing

Returns a mutable reference to the string at the given index.

§Arguments
  • index - The index of the string to be returned
§Examples
use cobia::*;

fn test_content(a: &mut CapeArrayEnumerationOut<cobia::CapePMCServiceType>) {
   assert_eq!(a.as_vec(), vec![cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM32]);
}
 
let mut arr = cobia::CapeArrayEnumerationVec::<cobia::CapePMCServiceType>::from_vec(vec![cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM32]);
test_content(&mut CapeArrayEnumerationOutFromProvider::from(&mut arr).as_cape_array_enumeration_out());
Source§

impl<'a, Element: Copy + Clone + 'a> IntoIterator for &'a CapeArrayEnumerationOut<'a, Element>

Source§

fn into_iter(self) -> CapeArrayRefIterator<'a, Element>

Return an iterator over the real array.

§Examples
use cobia::*;

fn test_iter(a: CapeArrayEnumerationOut<cobia::CapePMCServiceType>) {
	let mut hasCOM64=false;
	for val in a {
	    if val==cobia::CapePMCServiceType::COM64 {
	        hasCOM64=true;
	    }
	}
	assert!(hasCOM64);
}
 
let mut arr = cobia::CapeArrayEnumerationVec::<cobia::CapePMCServiceType>::from_vec(vec![cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64]);
test_iter(CapeArrayEnumerationOutFromProvider::from(&mut arr).as_cape_array_enumeration_out());
Source§

type Item = Element

The type of the elements being iterated over.
Source§

type IntoIter = CapeArrayRefIterator<'a, Element>

Which kind of iterator are we turning this into?
Source§

impl<'a, Element: Copy + Clone> IntoIterator for CapeArrayEnumerationOut<'a, Element>

Source§

fn into_iter(self) -> Self::IntoIter

Return an iterator over the real array.

§Examples
use cobia::*;

fn test_iter(a: CapeArrayEnumerationOut<cobia::CapePMCServiceType>) {
	let mut hasCOM64=false;
	for val in a {
	    if val==cobia::CapePMCServiceType::COM64 {
	        hasCOM64=true;
	    }
	}
	assert!(hasCOM64);
}
 
let mut arr = cobia::CapeArrayEnumerationVec::<cobia::CapePMCServiceType>::from_vec(vec![cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64]);
test_iter(CapeArrayEnumerationOutFromProvider::from(&mut arr).as_cape_array_enumeration_out());
Source§

type Item = Element

The type of the elements being iterated over.
Source§

type IntoIter = CapeArrayEnumerationIteratorOut<'a, Element>

Which kind of iterator are we turning this into?

Auto Trait Implementations§

§

impl<'a, Element> Freeze for CapeArrayEnumerationOut<'a, Element>

§

impl<'a, Element> RefUnwindSafe for CapeArrayEnumerationOut<'a, Element>
where Element: RefUnwindSafe,

§

impl<'a, Element> !Send for CapeArrayEnumerationOut<'a, Element>

§

impl<'a, Element> !Sync for CapeArrayEnumerationOut<'a, Element>

§

impl<'a, Element> Unpin for CapeArrayEnumerationOut<'a, Element>

§

impl<'a, Element> !UnwindSafe for CapeArrayEnumerationOut<'a, Element>

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.