Skip to main content

DynamicPortAccess

Trait DynamicPortAccess 

Source
pub trait DynamicPortAccess {
    // Required methods
    fn get_provided_port_as_any(
        &mut self,
        port_id: TypeId,
    ) -> Option<&mut (dyn Any + 'static)>;
    fn get_required_port_as_any(
        &mut self,
        port_id: TypeId,
    ) -> Option<&mut (dyn Any + 'static)>;
}
Expand description

A mechanism for dynamically getting references to provided/required ports from a component.

Should only be used if working with concrete types, or strict generic bounds (i.e. Provide, ProvideRef, etc.) is not an option. This is the case, for example, when working with Arc<dyn AbstractComponent>.

Required Methods§

Source

fn get_provided_port_as_any( &mut self, port_id: TypeId, ) -> Option<&mut (dyn Any + 'static)>

Internal API. Dynamically obtain a mutable reference to a ProvidedPort if self provides a port of the type indicated by the passed port_id.

This is a low-level API that is automatically implemented by #[derive(ComponentDefinition)]. Prefer the more strongly typed get_provided_port.

Source

fn get_required_port_as_any( &mut self, port_id: TypeId, ) -> Option<&mut (dyn Any + 'static)>

Internal API. Dynamically obtain a mutable reference to a RequiredPort if self requires a port of the type indicated by the passed port_id.

This is a low-level API that is automatically implemented by #[derive(ComponentDefinition)]. Prefer the more strongly typed get_required_port.

Implementors§