pub struct OperatorRegistry { /* private fields */ }Expand description
The static registration table astrs-runtime iterates by name.
use astrs_operator_api::{register_operator, OperatorRegistry, OpEvent, OpOutput, OpResult, Operator, Status};
#[derive(Default)]
struct Noop;
impl Operator for Noop {
fn on_event(&mut self, _event: &OpEvent, _out: &mut OpOutput) -> OpResult<Status> {
Ok(Status::Continue)
}
}
let registry = OperatorRegistry::from_entries([register_operator!(Noop)])?;
assert!(registry.contains("Noop"));
let operator = registry.build("Noop")?;
drop(operator);Implementations§
Source§impl OperatorRegistry
impl OperatorRegistry
Sourcepub fn from_entries(
entries: impl IntoIterator<Item = (&'static str, OperatorConstructor)>,
) -> OpResult<Self>
pub fn from_entries( entries: impl IntoIterator<Item = (&'static str, OperatorConstructor)>, ) -> OpResult<Self>
Builds a registry from a list of (name, constructor) entries —
exactly the shape register_operator! produces.
§Errors
OpError::DuplicateOperator if two entries share a name.
Sourcepub fn register(
&mut self,
name: &'static str,
constructor: OperatorConstructor,
) -> OpResult<()>
pub fn register( &mut self, name: &'static str, constructor: OperatorConstructor, ) -> OpResult<()>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for OperatorRegistry
impl !UnwindSafe for OperatorRegistry
impl Freeze for OperatorRegistry
impl Send for OperatorRegistry
impl Sync for OperatorRegistry
impl Unpin for OperatorRegistry
impl UnsafeUnpin for OperatorRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more