PluginRegistry

Struct PluginRegistry 

Source
pub struct PluginRegistry {
    pub registry: Registry,
    pub handlers: HandlerRegistry,
    pub current_prefix: Option<String>,
    pub capabilities: CapabilityRegistry,
    pub const_coercers: Arc<RwLock<HashMap<&'static str, Box<dyn Fn(&Value) -> Option<Box<dyn Any + Sync + Send>> + Sync + Send>>>>,
    pub output_movers: Arc<RwLock<HashMap<TypeId, Box<dyn Fn(Box<dyn Any + Sync + Send>) -> EdgePayload + Sync + Send>>>>,
    pub type_compatibilities: BTreeSet<(TypeExpr, TypeExpr)>,
}
Expand description

Container for descriptors + handlers. All nodes are installed via plugins.

Fields§

§registry: Registry§handlers: HandlerRegistry§current_prefix: Option<String>§capabilities: CapabilityRegistry§const_coercers: Arc<RwLock<HashMap<&'static str, Box<dyn Fn(&Value) -> Option<Box<dyn Any + Sync + Send>> + Sync + Send>>>>§output_movers: Arc<RwLock<HashMap<TypeId, Box<dyn Fn(Box<dyn Any + Sync + Send>) -> EdgePayload + Sync + Send>>>>§type_compatibilities: BTreeSet<(TypeExpr, TypeExpr)>

Implementations§

Source§

impl PluginRegistry

Source

pub fn new() -> PluginRegistry

Source

pub fn merge<N>(&mut self) -> Result<(), &'static str>
where N: NodeInstall,

Source

pub fn take_handlers(&mut self) -> HandlerRegistry

Source

pub fn register_conversion<S, T>(&mut self, f: fn(&S) -> Option<T>)
where S: 'static + Send + Sync + Any, T: 'static + Send + Sync + Any,

Register an application-specific CPU-side conversion (available to all nodes).

Source

pub fn register_const_coercer<T, F>(&mut self, coercer: F)
where T: Any + Send + Sync + 'static, F: Fn(&Value) -> Option<T> + Send + Sync + 'static,

Register a conversion for constant default values.

This is the preferred API for dynamic plugins so the host and plugin share a single coercer map stored in the host-owned PluginRegistry.

Source

pub fn register_value_serializer<T, F>(&mut self, serializer: F)
where T: Any + Clone + Send + Sync + 'static, F: Fn(&T) -> Value + Send + Sync + 'static,

Register a serializer for outbound host-bridge values.

This enables host-bridge serialization for plugin-defined structured payload types by converting them into daedalus_data::model::Value.

Source

pub fn register_output_mover<T, F>(&mut self, mover: F)
where T: Any + Send + Sync + 'static, F: Fn(T) -> EdgePayload + Send + Sync + 'static,

Register an output mover to emit a typed output payload by value.

Source

pub fn register_type_compatibility(&mut self, from: TypeExpr, to: TypeExpr)

Register a type-compatibility edge to support dynamic port polling.

Dynamic plugins should use this API so compat data is stored in the host registry.

Source

pub fn apply_type_compatibilities(&self)

Apply any registered compatibility edges to the host typing registry.

Source

pub fn register_enum<T>( &mut self, variants: impl IntoIterator<Item = impl Into<String>>, )
where T: Any + Send + Sync + 'static + DeserializeOwned,

Register an enum type for UI/typing and enable constant binding for it.

This lets node function signatures take a strongly-typed enum (e.g. mode: ExecMode) while allowing JSON-authored graphs to provide the value as either:

  • Value::Int(2) (index into the registered variant list)
  • Value::String("cpu") (variant name)
  • Value::Enum { name: "cpu", .. } (variant name)

The enum T must be DeserializeOwned so we can construct it from the variant name.

Source

pub fn register_capability_typed<T, F>(&mut self, key: impl Into<String>, f: F)
where T: Send + Sync + 'static, F: Fn(&T, &T) -> Result<T, NodeError> + Send + Sync + 'static,

Register a typed capability entry keyed by a string. The provided function operates on typed references; downcasting is handled internally.

Source

pub fn register_capability_typed3<T, F>(&mut self, key: impl Into<String>, f: F)
where T: Send + Sync + 'static, F: Fn(&T, &T, &T) -> Result<T, NodeError> + Send + Sync + 'static,

Register a typed capability entry that takes three operands of the same type.

Trait Implementations§

Source§

impl Default for PluginRegistry

Source§

fn default() -> PluginRegistry

Returns the “default value” for a type. Read more
Source§

impl RegistryPluginExt for PluginRegistry

Source§

fn install_plugin<P>(&mut self, plugin: &P) -> Result<(), &'static str>
where P: Plugin,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
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.