pub type CapeArrayByteVec = CapeArrayVec<CapeByte, ICapeArrayByte>;Expand description
Vector based CapeArrayByteOut implementation
ICapeArrayByte is passed as data container between CAPE-OPEN functions.
It is up to the caller to provide the interface, and its implementation.
This class provides a default impementation using a Vec<C::CapeByte>.
§Examples
use cobia::*;
fn set_content(a: &mut CapeArrayByteOut) {
a.put_array(&[2u8,4u8]).unwrap();
}
let mut arr = cobia::CapeArrayByteVec::from_slice(&[2u8,4u8]);
set_content(&mut CapeArrayByteOutFromProvider::from(&mut arr).as_cape_array_byte_out());
assert_eq!(arr.as_vec(), &vec![2u8,4u8]);Aliased Type§
pub struct CapeArrayByteVec {
vec: Vec<u8>,
interface_type: PhantomData<ICapeArrayByte>,
}Fields§
§vec: Vec<u8>§interface_type: PhantomData<ICapeArrayByte>Implementations§
Source§impl CapeArrayByteVec
impl CapeArrayByteVec
Sourceconst VTABLE: ICapeArrayByte_VTable
const VTABLE: ICapeArrayByte_VTable
Interface v-table
Sourceextern "C" fn get(
me: *mut c_void,
data: *mut *mut CapeByte,
size: *mut CapeSize,
)
extern "C" fn get( me: *mut c_void, data: *mut *mut CapeByte, size: *mut CapeSize, )
Interface member function
Sourceextern "C" fn setsize(
me: *mut c_void,
size: CapeSize,
data: *mut *mut CapeByte,
) -> CapeResult
extern "C" fn setsize( me: *mut c_void, size: CapeSize, data: *mut *mut CapeByte, ) -> CapeResult
Interface member function
Sourcepub fn resize(&mut self, size: usize)
pub fn resize(&mut self, size: usize)
Resize
Resize the array to the given size. If the size is larger than the current size, the new elements are set to 0.
§Arguments
size- The new size of the array
§Examples
use cobia;
use cobia::prelude::*;
let mut arr = cobia::CapeArrayByteVec::from_slice(&[2u8,4u8]);
arr.resize(4);
assert_eq!(arr.as_vec(), &vec![2u8,4u8,0,0]);Sourcepub fn set<T: CapeArrayByteProviderIn>(
&mut self,
array: &T,
) -> Result<(), COBIAError>
pub fn set<T: CapeArrayByteProviderIn>( &mut self, array: &T, ) -> Result<(), COBIAError>
Set the content of the byte array from any object that implements CapeArrayByteProviderIn.
§Arguments
array- An object that implements CapeArrayByteProviderIn
§Example
use cobia;
let mut arr = cobia::CapeArrayByteVec::new();
let arr1 = cobia::CapeArrayByteVec::from_slice(&[8,9,7]);
arr.set(&arr1);
assert_eq!(arr.as_vec(), &vec![8,9,7]);Trait Implementations§
Source§impl CapeArrayByteProviderIn for CapeArrayByteVec
impl CapeArrayByteProviderIn for CapeArrayByteVec
Source§fn as_cape_array_byte_in(&self) -> ICapeArrayByte
fn as_cape_array_byte_in(&self) -> ICapeArrayByte
Convert to ICapeArrayByte
Returns a reference to the ICapeArrayByte interface.
§Examples
use cobia::*;
use cobia::prelude::*;
let arr = cobia::CapeArrayByteVec::from_slice(&[9u8,10u8,2u8]);
let i_cape_array_byte=arr.as_cape_array_byte_in();
let mut i_cape_array_byte_ptr=(&i_cape_array_byte as *const C::ICapeArrayByte).cast_mut(); //normally a pointer to the interface is received
let a = cobia::CapeArrayByteIn::new(&mut i_cape_array_byte_ptr); //CapeArrayByteIn from *mut C::ICapeArrayByte
assert_eq!(a.as_vec(), vec![9u8,10u8,2u8]);Source§impl CapeArrayByteProviderOut for CapeArrayByteVec
impl CapeArrayByteProviderOut for CapeArrayByteVec
Source§fn as_cape_array_byte_out(&mut self) -> ICapeArrayByte
fn as_cape_array_byte_out(&mut self) -> ICapeArrayByte
Convert to ICapeArrayByte
Returns a mutable reference to the ICapeArrayByte interface.
§Examples
use cobia::*;
use cobia::prelude::*;
let mut arr = cobia::CapeArrayByteVec::from_slice(&[9u8,10u8,2u8]);
let i_cape_array_byte=arr.as_cape_array_byte_out();
let mut i_cape_array_byte_ptr=(&i_cape_array_byte as *const C::ICapeArrayByte).cast_mut(); //normally a pointer to the interface is received
let a = cobia::CapeArrayByteOut::new(&mut i_cape_array_byte_ptr); //CapeArrayByteOut from *mut C::ICapeArrayByte
assert_eq!(a.as_vec(), vec![9u8,10u8,2u8]);Source§impl<T: CapeArrayByteProviderIn> PartialEq<T> for CapeArrayByteVec
impl<T: CapeArrayByteProviderIn> PartialEq<T> for CapeArrayByteVec
Source§fn eq(&self, other: &T) -> bool
fn eq(&self, other: &T) -> bool
Partial equality
Checks if the CapeArrayByteVec is equal to another CapeArrayByteProviderIn.
§Arguments
other- The other CapeArrayByteProviderIn to compare with
§Examples
use cobia::*;
use cobia::prelude::*;
let arr1 = cobia::CapeArrayByteVec::from_slice(&[2u8,4u8]);
let arr2 = cobia::CapeArrayByteVec::from_slice(&[2u8,4u8]);
let arr3 = cobia::CapeArrayByteVec::from_slice(&[2u8,3u8,4u8]);
assert!(arr1 == arr2);
assert!(arr1 != arr3);