Struct CapeArrayEnumerationIn

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

CapeArrayEnumerationIn wraps an ICapeArrayEnumeration interface pointer.

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

This interface is typically used as arguments to rust methods on traits that are generated from CAPE-OPEN interfaces that have ICapeArrayEnumeration input 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)

A NULL pointer is treated as an empty array.

§Examples

use cobia::*;

fn test_content(a: &CapeArrayEnumerationIn<cobia::CapePMCServiceType>) {
    assert_eq!(a.as_vec(), vec![cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64]);
}
 
let arr = cobia::CapeArrayEnumerationVec::from_slice(&[cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64]);
test_content(&CapeArrayEnumerationInFromProvider::from(&arr).as_cape_array_enumeration_in());

Fields§

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

Implementations§

Source§

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

Source

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

Create a new CapeArrayEnumerationIn from an ICapeArrayEnumeration interface pointer.

§Arguments
  • interface - A pointer to an ICapeArrayEnumeration interface
§Examples
use cobia::*;
use cobia::prelude::*;
let arr = cobia::CapeArrayEnumerationVec::<cobia::CapePMCServiceType>::from_slice(&[cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64]);
let i_cape_array_enumeration=arr.as_cape_array_enumeration_in();
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::CapeArrayEnumerationIn::<cobia::CapePMCServiceType>::new(&mut i_cape_array_enumeration_ptr); //CapeArrayEnumerationIn from *mut C::ICapeArrayEnumeration
assert_eq!(a.as_vec(), vec![cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64]);
Source

pub fn size(&self) -> usize

Return the size of the array

§Examples
use cobia::*;

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

pub fn is_empty(&self) -> bool

Check if the array is empty

§Examples
use cobia::*;

fn test_empty(a: &CapeArrayEnumerationIn<cobia::CapePMCServiceType>) {
    assert!(a.is_empty());
}
 
let arr = cobia::CapeArrayEnumerationVec::<cobia::CapePMCServiceType>::new();
test_empty(&CapeArrayEnumerationInFromProvider::from(&arr).as_cape_array_enumeration_in());
Source

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

Return the content of the array as a vector.

§Examples
use cobia::*;

fn test_content(a: &CapeArrayEnumerationIn<cobia::CapePMCServiceType>) {
    assert_eq!(a.as_vec(), vec![cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64]);
}
 
let arr = cobia::CapeArrayEnumerationVec::<cobia::CapePMCServiceType>::from_slice(&[cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64]);
test_content(&CapeArrayEnumerationInFromProvider::from(&arr).as_cape_array_enumeration_in());
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: &CapeArrayEnumerationIn<cobia::CapePMCServiceType>) {
    assert_eq!(a.as_slice(), &[cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64]);
}
 
let arr = cobia::CapeArrayEnumerationVec::<cobia::CapePMCServiceType>::from_vec(vec![cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64]);
test_content(&CapeArrayEnumerationInFromProvider::from(&arr).as_cape_array_enumeration_in());
Source

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

Return an iterator for the array.

§Examples
use cobia::*;

fn test_iter(a: &CapeArrayEnumerationIn<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 arr = cobia::CapeArrayEnumerationVec::<cobia::CapePMCServiceType>::from_vec(vec![cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64]);
test_iter(&CapeArrayEnumerationInFromProvider::from(&arr).as_cape_array_enumeration_in());

Trait Implementations§

Source§

impl<'a, Element: Copy + Clone> CapeArrayEnumerationProviderIn for CapeArrayEnumerationIn<'a, Element>

Source§

fn as_cape_array_enumeration_in(&self) -> ICapeArrayEnumeration

Convert to ICapeArrayEnumeration
Source§

impl<'a, Element: Copy + Clone + Display> Display for CapeArrayEnumerationIn<'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: &CapeArrayEnumerationIn<cobia::CapePMCServiceType>) {
    assert_eq!(format!("{}", a), "[Inproc64, COM64, Local]");
}
 
let arr = cobia::CapeArrayEnumerationVec::<cobia::CapePMCServiceType>::from_vec(vec![cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64,cobia::CapePMCServiceType::Local]);
test_format(&CapeArrayEnumerationInFromProvider::from(&arr).as_cape_array_enumeration_in());
Source§

impl<'a, Element: Copy + Clone> Index<usize> for CapeArrayEnumerationIn<'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_item(a: &CapeArrayEnumerationIn<cobia::CapePMCServiceType>) {
	assert_eq!(a[1], cobia::CapePMCServiceType::COM64);
}
 
let arr = cobia::CapeArrayEnumerationVec::<cobia::CapePMCServiceType>::from_vec(vec![cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64]);
test_item(&CapeArrayEnumerationInFromProvider::from(&arr).as_cape_array_enumeration_in());
Source§

type Output = Element

The returned type after indexing.
Source§

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

Source§

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

Return an iterator over the real array.

§Examples
use cobia::*;

fn test_iter(a: &CapeArrayEnumerationIn<cobia::CapePMCServiceType>) {
	let mut hasCOM64=false;
	for val in a {
	 if val==cobia::CapePMCServiceType::COM64 {
		    hasCOM64=true;
	 }
	}
	assert!(hasCOM64);
}
 
let arr = cobia::CapeArrayEnumerationVec::<cobia::CapePMCServiceType>::from_vec(vec![cobia::CapePMCServiceType::Inproc64,cobia::CapePMCServiceType::COM64]);
test_iter(&CapeArrayEnumerationInFromProvider::from(&arr).as_cape_array_enumeration_in());
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 CapeArrayEnumerationIn<'a, Element>

Source§

fn into_iter(self) -> Self::IntoIter

Return an iterator over the real array.

§Examples
use cobia::*;

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

type Item = Element

The type of the elements being iterated over.
Source§

type IntoIter = CapeArrayEnumerationIteratorIn<'a, Element>

Which kind of iterator are we turning this into?

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<'a, Element> UnwindSafe for CapeArrayEnumerationIn<'a, Element>
where Element: 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> 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.