pub struct Plexus { /* private fields */ }Expand description
A Plexus manages a network of Ganglia, arranging automatic transmission of types between different Ganglia. This is the Rust equivalent of the Python Plexus class.
Implementations§
Source§impl Plexus
impl Plexus
Sourcepub async fn neurons(
&self,
) -> RwLockReadGuard<'_, HashMap<String, Arc<dyn NeuronErased + Send + Sync + 'static>>>
pub async fn neurons( &self, ) -> RwLockReadGuard<'_, HashMap<String, Arc<dyn NeuronErased + Send + Sync + 'static>>>
Returns a read guard to the neurons map
Sourcepub async fn new(
relevant_neurons: Vec<Arc<dyn NeuronErased + Send + Sync + 'static>>,
ignored_neurons: Vec<Arc<dyn NeuronErased + Send + Sync + 'static>>,
) -> Self
pub async fn new( relevant_neurons: Vec<Arc<dyn NeuronErased + Send + Sync + 'static>>, ignored_neurons: Vec<Arc<dyn NeuronErased + Send + Sync + 'static>>, ) -> Self
Create a new Plexus with the given ganglia and neuron filters
Helper to create an Arc<Mutex
Sourcepub async fn infuse_ganglion<G>(
&mut self,
ganglion: Arc<Mutex<G>>,
) -> Result<(), PlexusError>
pub async fn infuse_ganglion<G>( &mut self, ganglion: Arc<Mutex<G>>, ) -> Result<(), PlexusError>
Add a ganglion to the plexus
Sourcepub async fn infuse_external_ganglion<G>(
&mut self,
ganglion: Arc<Mutex<G>>,
) -> Result<(), PlexusError>
pub async fn infuse_external_ganglion<G>( &mut self, ganglion: Arc<Mutex<G>>, ) -> Result<(), PlexusError>
Add an external ganglion to the plexus
Sourcepub async fn excise_ganglion_by_id(
&mut self,
ganglion_id: Uuid,
) -> Result<Option<Arc<Mutex<dyn GanglionInternal + Send + Sync + 'static>>>, PlexusError>
pub async fn excise_ganglion_by_id( &mut self, ganglion_id: Uuid, ) -> Result<Option<Arc<Mutex<dyn GanglionInternal + Send + Sync + 'static>>>, PlexusError>
Remove a ganglion from the plexus by its ID
Sourcepub async fn excise_ganglion<G>(
&mut self,
ganglion: Arc<Mutex<G>>,
) -> Result<Option<Arc<Mutex<dyn GanglionInternal + Send + Sync + 'static>>>, PlexusError>
pub async fn excise_ganglion<G>( &mut self, ganglion: Arc<Mutex<G>>, ) -> Result<Option<Arc<Mutex<dyn GanglionInternal + Send + Sync + 'static>>>, PlexusError>
Remove a ganglion from the plexus
Sourcepub async fn excise_external_ganglion_by_id(
&mut self,
ganglion_id: Uuid,
) -> Result<Option<Arc<Mutex<dyn GanglionExternal + Send + Sync + 'static>>>, PlexusError>
pub async fn excise_external_ganglion_by_id( &mut self, ganglion_id: Uuid, ) -> Result<Option<Arc<Mutex<dyn GanglionExternal + Send + Sync + 'static>>>, PlexusError>
Remove an external ganglion from the plexus by its ID
Sourcepub async fn excise_external_ganglion<G>(
&mut self,
ganglion: Arc<Mutex<G>>,
) -> Result<Option<Arc<Mutex<dyn GanglionExternal + Send + Sync + 'static>>>, PlexusError>
pub async fn excise_external_ganglion<G>( &mut self, ganglion: Arc<Mutex<G>>, ) -> Result<Option<Arc<Mutex<dyn GanglionExternal + Send + Sync + 'static>>>, PlexusError>
Remove an external ganglion from the plexus
Sourcepub async fn update_neurons(
&self,
neuron: Arc<dyn NeuronErased + Send + Sync + 'static>,
) -> Result<(), PlexusError>
pub async fn update_neurons( &self, neuron: Arc<dyn NeuronErased + Send + Sync + 'static>, ) -> Result<(), PlexusError>
Update neurons with a new neuron
Trait Implementations§
Source§impl Ganglion for Plexus
impl Ganglion for Plexus
Source§impl GanglionInternal for Plexus
impl GanglionInternal for Plexus
fn transmit( &mut self, payload: Arc<dyn PayloadErased + Send + Sync + 'static>, ) -> Pin<Box<dyn Future<Output = Result<Vec<()>, GanglionError>> + Send + 'static>>
fn react( &mut self, neuron_name: String, reactants: Vec<Arc<dyn ReactantErased + Send + Sync + 'static>>, error_reactants: Vec<Arc<dyn ErrorReactantErased + Send + Sync>>, ) -> Pin<Box<dyn Future<Output = Result<(), GanglionError>> + Send + 'static>>
fn unique_id(&self) -> Uuid
Auto Trait Implementations§
impl Freeze for Plexus
impl !RefUnwindSafe for Plexus
impl Send for Plexus
impl Sync for Plexus
impl Unpin for Plexus
impl !UnwindSafe for Plexus
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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