Struct PortCollection

Source
pub(crate) struct PortCollection {
    name: CapeStringImpl,
    description: CapeStringImpl,
    ports: Vec<CapeUnitPort>,
    shared_unit_data: Rc<RefCell<SharedUnitData>>,
    cobia_object_data: PortCollectionCobiaObjectData,
}
Expand description

The PortCollection class implements a CAPE-OPEN 1.2 collection of unit ports for the DistillationShortcutUnit.

It provides methods to manage and access the ports associated with the unit.

Fields§

§name: CapeStringImpl

The name of the port collection

§description: CapeStringImpl

The description of the port collection

§ports: Vec<CapeUnitPort>

The ports contained in this collection

§shared_unit_data: Rc<RefCell<SharedUnitData>>

Shared data for the unit, allowing access to common properties.

§cobia_object_data: PortCollectionCobiaObjectData

Cobia object data for this object, which contains generated code to provide the native COBIA interfaces

Implementations§

Source§

impl PortCollection

Source

fn create_instance( _port_collection_boxed_ptr: *mut *mut ICapeInterface, shared_unit_data: Rc<RefCell<SharedUnitData>>, ) -> CapeResult

Source

pub(crate) fn create<T: CapeSmartPointer>( shared_unit_data: Rc<RefCell<SharedUnitData>>, ) -> T

Create a new instance of the object and return a smart pointer to it

This function panics if the created object does not implement the interface corresponding to the smart pointer to be returned. For a non-panic version, use the try_create() function.

Source

pub(crate) fn try_create<T: CapeSmartPointer>( shared_unit_data: Rc<RefCell<SharedUnitData>>, ) -> Result<T, COBIAError>

Create a new instance of the object and return a smart pointer to it

This function returns an error if the created object does not implement the interface corresponding to the smart pointer to be returned.

Source

pub(crate) unsafe fn borrow<T: CapeSmartPointer>(smart_pointer: &T) -> &Self

Get a reference to the object

Note that as the reference is created from a smart pointer, the reference is valid only as long as the smart pointer is valid. The reference is not checked for multiple borrows

§Safety

The user must ensure that the smart pointer contains a valid object, and that the object is of the type that is being borrowed. It is not possible for the compiler to check this, as the borrow is done through the native object pointer in the interface.

Source

pub(crate) unsafe fn borrow_mut<T: CapeSmartPointer>( smart_pointer: &mut T, ) -> &mut Self

Get a mutable reference to the object

Note that as the reference is created from a smart pointer, the reference is valid only as long as the smart pointer is valid. The reference is not checked for multiple borrows

§Safety

This function is unsafe because it allows mutable access to the object. Also the user must ensure that the smart pointer contains a valid object, and that the object is of the type that is being borrowed. It is not possible for the compiler to check this, as the borrow is done through the native object pointer in the interface.

Source§

impl PortCollection

Source

fn new(shared_unit_data: Rc<RefCell<SharedUnitData>>) -> Self

Creates a new PortCollection for the distillation shortcut unit.

§Arguments
  • shared_unit_data - A reference to shared data for the unit, which contains common properties.
§Returns

A new instance of PortCollection initialized with the provided shared data.

Source

pub(crate) fn add_port(&mut self, port: CapeUnitPort)

Adds a port to the collection.

§Arguments
  • port - The port to be added to the collection.
Source

pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut CapeUnitPort>

Obtain an iterator to iterate over the ports in the collection.

§Returns

An iterator that yields references to the ports in the collection.

Trait Implementations§

Source§

impl Display for PortCollection

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the port collection for display.

The std::fmt::Display interface is used when generating the source name of the object that raises an error.

§Arguments
  • f - A mutable reference to the formatter where the output will be written.
§Returns

A result indicating whether the formatting was successful or not.

Source§

impl ICapeCollection<CapeUnitPort> for PortCollection

Source§

fn item_by_index( &mut self, index: CapeInteger, ) -> Result<CapeUnitPort, COBIAError>

Retrieves a port by its index.

§Arguments
  • index - The index of the port to retrieve.
§Returns
  • A Result containing the port if found, or an error if the index is out of bounds.
Source§

fn item_by_name( &mut self, name: &CapeStringIn<'_>, ) -> Result<CapeUnitPort, COBIAError>

Retrieves a port by its name.

§Arguments
  • name - A reference to a CapeStringIn containing the name of the port to retrieve.
§Returns
  • A Result containing the port if found, or an error if no such item exists.
Source§

fn get_count(&mut self) -> Result<CapeInteger, COBIAError>

Retrieves the number of ports in the collection.

§Returns
  • A Result containing the number of ports as a CapeInteger.
Source§

impl ICapeCollectionImpl<CapeUnitPort> for PortCollection

Source§

type T = PortCollection

Source§

fn as_interface_pointer(&mut self) -> *mut ICapeInterface

§

fn init_interface() -> _ICapeInterface

prepare CAPEOPEN_1_2_ICapeCollection interface and return as generic ICapeInterface pointer
§

fn init<Timpl>(u: &mut Timpl)
where Timpl: ICapeCollectionImpl<CollectionItem> + ICapeInterfaceImpl,

§

extern "C" fn raw_item_by_index( me: *mut c_void, index: i32, item: *mut *mut _ICapeInterface, ) -> u32

§

extern "C" fn raw_item_by_name( me: *mut c_void, name: *mut _ICapeString, item: *mut *mut _ICapeInterface, ) -> u32

§

extern "C" fn raw_get_count( me: *mut c_void, item_count: *mut i32, ) -> u32

§

const VTABLE: CAPEOPEN_1_2_ICapeCollection_VTable = _

Source§

impl ICapeIdentification for PortCollection

Source§

fn get_component_name( &mut self, name: &mut CapeStringOut<'_>, ) -> Result<(), COBIAError>

Get the name of the component.

§Arguments
  • name - A mutable reference to a CapeStringOut where the name will be set.
§Returns
  • A Result indicating success or failure. If successful, the name is set in name.
Source§

fn get_component_description( &mut self, description: &mut CapeStringOut<'_>, ) -> Result<(), COBIAError>

Get the description of the component.

§Arguments
  • description - A mutable reference to a CapeStringOut where the description will be set.
§Returns
  • A Result indicating success or failure. If successful, the description is set in description.
Source§

fn set_component_name( &mut self, _name: &CapeStringIn<'_>, ) -> Result<(), COBIAError>

Set the name of the component.

§Arguments
  • name - A reference to a CapeStringIn containing the new name to be set.
§Returns
  • A Result indicating success or failure. This method is not allowed for this port implementation and will return an error.
Source§

fn set_component_description( &mut self, _desc: &CapeStringIn<'_>, ) -> Result<(), COBIAError>

Set the description of the component.

§Arguments
  • desc - A reference to a CapeStringIn containing the new description to be set.
§Returns
  • A Result indicating success or failure. This method is not allowed for this port implementation and will return an error.
Source§

impl ICapeIdentificationImpl for PortCollection

Source§

type T = PortCollection

Source§

fn as_interface_pointer(&mut self) -> *mut ICapeInterface

§

fn init_interface() -> _ICapeInterface

prepare CAPEOPEN_1_2_ICapeIdentification interface and return as generic ICapeInterface pointer
§

fn init<Timpl>(u: &mut Timpl)
where Timpl: ICapeIdentificationImpl + ICapeInterfaceImpl,

§

extern "C" fn raw_get_component_name( me: *mut c_void, name: *mut _ICapeString, ) -> u32

§

extern "C" fn raw_set_component_name( me: *mut c_void, name: *mut _ICapeString, ) -> u32

§

extern "C" fn raw_get_component_description( me: *mut c_void, desc: *mut _ICapeString, ) -> u32

§

extern "C" fn raw_set_component_description( me: *mut c_void, desc: *mut _ICapeString, ) -> u32

§

const VTABLE: CAPEOPEN_1_2_ICapeIdentification_VTable = _

Source§

impl ICapeInterfaceImpl for PortCollection

Source§

type T = PortCollection

Source§

fn get_object_data(&mut self) -> &mut CapeObjectData

Returns a mutable reference to the internal CapeObjectData structure.
Source§

fn get_self(&mut self) -> *mut PortCollection

Returns a pointer to the implementing object.
§

const CAPEINTERFACE_VTABLE: ICapeInterface_VTable = _

the V-table for the ICapeInterface implementation.
§

fn init(&mut self) -> *mut _ICapeInterface

Initializes the object, setting up the interface pointer and adding it to the interface map.
§

fn create_object_data<Timpl>() -> CapeObjectData
where Timpl: ICapeInterfaceImpl,

Utility function for internal object setup
§

extern "C" fn raw_add_reference(me: *mut c_void)

§

extern "C" fn raw_release(me: *mut c_void)

§

extern "C" fn raw_query_interface( me: *mut c_void, uuid: *const _CapeUUID, interface: *mut *mut _ICapeInterface, ) -> u32

§

extern "C" fn raw_get_last_error( me: *mut c_void, error: *mut *mut _ICapeError, ) -> u32

§

fn add_interface( &mut self, uuid: *const _CapeUUID, interface: *mut _ICapeInterface, )

Utility function to add an interface to the interface map. Read more
§

fn set_last_error(&mut self, error: COBIAError, scope: &str) -> u32

Utility function to set the last error and scope. Read more
§

fn clear_last_error(&mut self)

Utility function to clear the last error and scope.
§

fn as_icapeinterface(&mut self) -> *mut _ICapeInterface

Returns a unique pointer to the ICapeInterface implementation of the object.

Auto Trait Implementations§

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.