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: CapeSizeImplementations§
Source§impl<'a, Element: Copy + Clone> CapeArrayEnumerationIn<'a, Element>
impl<'a, Element: Copy + Clone> CapeArrayEnumerationIn<'a, Element>
Sourcepub fn new(interface: &'a *mut ICapeArrayEnumeration) -> Self
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]);Sourcepub fn size(&self) -> usize
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());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: &CapeArrayEnumerationIn<cobia::CapePMCServiceType>) {
assert!(a.is_empty());
}
let arr = cobia::CapeArrayEnumerationVec::<cobia::CapePMCServiceType>::new();
test_empty(&CapeArrayEnumerationInFromProvider::from(&arr).as_cape_array_enumeration_in());Sourcepub fn as_vec(&self) -> Vec<Element>
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());Sourcepub fn as_slice(&self) -> &[Element]
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());Sourcepub fn iter(&self) -> CapeArrayRefIterator<'_, Element> ⓘ
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>
impl<'a, Element: Copy + Clone> CapeArrayEnumerationProviderIn for CapeArrayEnumerationIn<'a, Element>
Source§fn as_cape_array_enumeration_in(&self) -> ICapeArrayEnumeration
fn as_cape_array_enumeration_in(&self) -> ICapeArrayEnumeration
Source§impl<'a, Element: Copy + Clone + Display> Display for CapeArrayEnumerationIn<'a, Element>
impl<'a, Element: Copy + Clone + Display> Display for CapeArrayEnumerationIn<'a, Element>
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
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>
impl<'a, Element: Copy + Clone> Index<usize> for CapeArrayEnumerationIn<'a, Element>
Source§fn index(&self, index: usize) -> &Self::Output
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§impl<'a, Element: Copy + Clone + 'a> IntoIterator for &'a CapeArrayEnumerationIn<'a, Element>
impl<'a, Element: Copy + Clone + 'a> IntoIterator for &'a CapeArrayEnumerationIn<'a, Element>
Source§fn into_iter(self) -> CapeArrayRefIterator<'a, Element> ⓘ
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 IntoIter = CapeArrayRefIterator<'a, Element>
type IntoIter = CapeArrayRefIterator<'a, Element>
Source§impl<'a, Element: Copy + Clone> IntoIterator for CapeArrayEnumerationIn<'a, Element>
impl<'a, Element: Copy + Clone> IntoIterator for CapeArrayEnumerationIn<'a, Element>
Source§fn into_iter(self) -> Self::IntoIter
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());