Struct CobiaCollectionBase

Source
pub struct CobiaCollectionBase<Element: CapeSmartPointer> {
    interface: *mut ICobiaCollection,
    element_type: PhantomData<Element>,
}
Expand description

CobiaCollectionBase wraps an collection interface

The collection interface is returned in case muliple objects are returned by a method.

Collection items each must have a unique name, and the name is exposed from the approproate identification interface.

Collection items are accessed by index or by name.

#Example

use cobia;
use cobia::prelude::*;
cobia::cape_open_initialize().unwrap();
let library_enumerator = cobia::CapeTypeLibraries::new().unwrap();
let libraries = library_enumerator.libraries().unwrap(); //this is a CobiaCollection smart pointer
assert!(libraries.size() > 0); //normally the CAPE-OPEN type libraries are registered
cobia::cape_open_cleanup();

Fields§

§interface: *mut ICobiaCollection§element_type: PhantomData<Element>

Implementations§

Source§

impl<Element: CapeSmartPointer> CobiaCollectionBase<Element>

Source

pub(crate) fn from_interface_pointer(interface: *mut ICobiaCollection) -> Self

Create a new CobiaCollectionBase from an interface pointer

This member is not typically called. Instead, the CobiaCollectionBase is created by the API functions that return it.

§Safety

The interface pointer must be valid and must point to an object that implements the ICobiaCollection interface.

§Panics

This function panics if the interface pointer is null.

Source

pub(crate) fn attach(interface: *mut ICobiaCollection) -> Self

Create a new CobiaCollectionBase from an interface pointer without adding a reference

This member is not typically called. Instead, the CobiaCollectionBase is created by the API functions that return it.

§Safety

The interface pointer must be valid and must point to an object that implements the ICobiaCollection interface.

§Panics

This function panics if the interface pointer is null.

Source

pub fn size(&self) -> usize

Get the number of elements in the collection

§Examples
use cobia;
use cobia::prelude::*;
cobia::cape_open_initialize().unwrap();
let library_enumerator = cobia::CapeTypeLibraries::new().unwrap();
let libraries = library_enumerator.libraries().unwrap(); //this is a CobiaCollection smart pointer
assert!(libraries.size() > 0); //normally the CAPE-OPEN type libraries are registered
cobia::cape_open_cleanup();
Source

pub fn at(&self, index: usize) -> Result<Element, COBIAError>

Get a collection item by index in the collection

The index is zero-based, and must be 0 <= index < size().

Note that the collection implements iterators, but not the Index or IndexMut trait, as both these traits require returning the item by reference, which is not possible in this context, as the returned object owns the interface pointer.

§Examples
use cobia;
use cobia::prelude::*;
cobia::cape_open_initialize().unwrap();
let library_enumerator = cobia::CapeTypeLibraries::new().unwrap();
let libraries = library_enumerator.libraries().unwrap(); //this is a CobiaCollection smart pointer
assert!(libraries.size() > 0); //normally the CAPE-OPEN type libraries are registered
let library = libraries.at(0).unwrap();
cobia::cape_open_cleanup();
Source

pub fn get(&self, id: &str) -> Result<Element, COBIAError>

Get a collection item by name

The name is case insentive, but must correspond to one of the items in the collection.

§Examples
use cobia;
use cobia::prelude::*;
cobia::cape_open_initialize().unwrap();
let library_enumerator = cobia::CapeTypeLibraries::new().unwrap();
let libraries = library_enumerator.libraries().unwrap(); //this is a CobiaCollection smart pointer
assert!(libraries.size() > 0); //normally the CAPE-OPEN type libraries are registered
let library = libraries.at(0).unwrap();
let lib_name = library.get_name().unwrap();
let library1 = libraries.get(&lib_name).unwrap();
assert_eq!(library.get_uuid().unwrap(),library1.get_uuid().unwrap());
cobia::cape_open_cleanup();
Source

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

Get an iterator for the collection by reference

This iterator does not consume the collection.

§Examples
use cobia;
use cobia::prelude::*;
cobia::cape_open_initialize().unwrap();
let library_enumerator = cobia::CapeTypeLibraries::new().unwrap();
let libraries = library_enumerator.libraries().unwrap(); //this is a CobiaCollection smart pointer
let mut found=false;
for library in libraries.iter() {
    let lib_name = library.get_name().unwrap();
    if lib_name=="CAPEOPEN_1_2" { //performance note: this is not efficient, but it is an example
        found=true;
   		break;
    }
}
assert!(found);
cobia::cape_open_cleanup();

Trait Implementations§

Source§

impl<Element: CapeSmartPointer> CapeSmartPointer for CobiaCollectionBase<Element>

Source§

type Interface = ICobiaCollection

Source§

fn as_interface_pointer(&self) -> *mut Self::Interface

Get the interface pointer Read more
Source§

fn as_cape_interface_pointer(&self) -> *mut ICapeInterface

Get the ICapeInterface Read more
Source§

fn get_interface_id() -> &'static CapeUUID

Get the interface ID Read more
Source§

fn from_object<T: CapeSmartPointer>( smart_pointer: &T, ) -> Result<Self, COBIAError>

Get an interface wrapper instance from another object Read more
Source§

fn from_interface_pointer(interface: *mut Self::Interface) -> Self

Get an interface wrapper instance from an interface pointer of the wrapped type Read more
Source§

fn attach(interface: *mut Self::Interface) -> Self

Get an interface wrapper instance from an interface pointer of the wrapped type, without adding a reference Read more
Source§

fn detach(self) -> *mut Self::Interface

Return an interface pointer and release ownership, without decreasing a reference Read more
Source§

fn from_cape_interface_pointer( interface: *mut ICapeInterface, ) -> Result<Self, COBIAError>

Get an interface wrapper instance from any interface pointer Read more
Source§

fn last_error(&self) -> Option<CapeError>

Get the last error Read more
Source§

impl<Element: CapeSmartPointer> Clone for CobiaCollectionBase<Element>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Element: CapeSmartPointer> Drop for CobiaCollectionBase<Element>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'a, Element: CapeSmartPointer> IntoIterator for &'a CobiaCollectionBase<Element>

Source§

type Item = Element

The type of the elements being iterated over.
Source§

type IntoIter = CobiaCollectionBaseRefIterator<'a, Element>

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<Element: CapeSmartPointer> IntoIterator for CobiaCollectionBase<Element>

Source§

type Item = Element

The type of the elements being iterated over.
Source§

type IntoIter = CobiaCollectionBaseIterator<Element>

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<Element> Freeze for CobiaCollectionBase<Element>

§

impl<Element> RefUnwindSafe for CobiaCollectionBase<Element>
where Element: RefUnwindSafe,

§

impl<Element> !Send for CobiaCollectionBase<Element>

§

impl<Element> !Sync for CobiaCollectionBase<Element>

§

impl<Element> Unpin for CobiaCollectionBase<Element>
where Element: Unpin,

§

impl<Element> UnwindSafe for CobiaCollectionBase<Element>
where Element: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.