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: CapeSizeImplementations§
Source§impl<'a, Element: Copy + Clone> CapeArrayEnumerationOut<'a, Element>
impl<'a, Element: Copy + Clone> CapeArrayEnumerationOut<'a, Element>
Sourcepub fn new(interface: &'a mut *mut ICapeArrayEnumeration) -> Self
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]);Sourcepub fn size(&self) -> usize
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());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: &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());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: &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());Sourcepub fn put_array(&mut self, array: &[Element]) -> Result<(), COBIAError>
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>Sourcepub fn resize(&mut self, size: usize) -> Result<(), COBIAError>
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); 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: &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());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: &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>
impl<'a, Element: Copy + Clone> CapeArrayEnumerationProviderOut for CapeArrayEnumerationOut<'a, Element>
Source§fn as_cape_array_enumeration_out(&mut self) -> ICapeArrayEnumeration
fn as_cape_array_enumeration_out(&mut self) -> ICapeArrayEnumeration
Source§impl<'a, Element: Copy + Clone + Display> Display for CapeArrayEnumerationOut<'a, Element>
impl<'a, Element: Copy + Clone + Display> Display for CapeArrayEnumerationOut<'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: &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>
impl<'a, Element: Copy + Clone> Index<usize> for CapeArrayEnumerationOut<'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_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§impl<'a, Element: Copy + Clone> IndexMut<usize> for CapeArrayEnumerationOut<'a, Element>
impl<'a, Element: Copy + Clone> IndexMut<usize> for CapeArrayEnumerationOut<'a, Element>
Source§fn index_mut(&mut self, index: usize) -> &mut Self::Output
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>
impl<'a, Element: Copy + Clone + 'a> IntoIterator for &'a CapeArrayEnumerationOut<'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: 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 IntoIter = CapeArrayRefIterator<'a, Element>
type IntoIter = CapeArrayRefIterator<'a, Element>
Source§impl<'a, Element: Copy + Clone> IntoIterator for CapeArrayEnumerationOut<'a, Element>
impl<'a, Element: Copy + Clone> IntoIterator for CapeArrayEnumerationOut<'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: 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());