#[non_exhaustive]pub enum ModularAgentEvent {
AgentConfigUpdated(String, String, AgentValue),
AgentError(String, String),
AgentIn(String, String),
AgentSpecUpdated(String),
PresetStructureChanged {
preset_id: String,
},
PresetAdded {
preset_id: String,
name: Option<String>,
},
PresetRemoved {
preset_id: String,
name: Option<String>,
},
PresetRenamed {
preset_id: String,
old_name: Option<String>,
new_name: String,
},
PresetSaved {
preset_id: String,
name: String,
},
ExternalOutput(String, AgentValue),
}Expand description
Events emitted by ModularAgent during operation.
Subscribe to these events using ModularAgent::subscribe or
ModularAgent::subscribe_to_event.
§Example
use modular_agent_core::{ModularAgent, ModularAgentEvent};
// Subscribe to all external output events
let mut rx = ma.subscribe_to_event(|envelope| {
if let ModularAgentEvent::ExternalOutput(name, value) = envelope.event {
Some((name, value))
} else {
None
}
});Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
AgentConfigUpdated(String, String, AgentValue)
An agent’s configuration was updated.
Fields: (agent_id, config_key, new_value)
AgentError(String, String)
An agent encountered an error.
Fields: (agent_id, error_message)
AgentIn(String, String)
An agent received input on a port.
Fields: (agent_id, port_name)
AgentSpecUpdated(String)
An agent’s spec was updated.
Fields: (agent_id)
PresetStructureChanged
A preset’s structure (agents, connections, or non-config spec keys) was changed.
Emitted by ModularAgent::add_agent, ModularAgent::remove_agent,
ModularAgent::add_connection, ModularAgent::remove_connection,
ModularAgent::add_agents_and_connections,
ModularAgent::update_preset_spec, and by
ModularAgent::update_agent_spec when the patch contains keys other
than configs, so hosts can refresh their view of the preset.
PresetAdded
A preset was added.
Emitted whenever a preset is created or loaded
(ModularAgent::new_preset, ModularAgent::add_preset, their
named variants, and open_preset_from_file).
PresetRemoved
A preset was removed.
Emitted by ModularAgent::remove_preset after the preset and its
agents have been torn down, so hosts can close any view of it.
PresetRenamed
A preset was renamed.
Emitted by ModularAgent::rename_preset. old_name is None when
the preset had no name before.
PresetSaved
A named preset was saved to disk.
Emitted by ModularAgent::save_preset; unnamed presets produce no
event.
ExternalOutput(String, AgentValue)
A value was written to an external output channel.
This event is emitted when:
ModularAgent::write_external_inputis called and flows through the network- An
ExternalOutputAgentreceives a value
Fields: (channel_name, value)
Trait Implementations§
Source§impl Clone for ModularAgentEvent
impl Clone for ModularAgentEvent
Source§fn clone(&self) -> ModularAgentEvent
fn clone(&self) -> ModularAgentEvent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ModularAgentEvent
impl RefUnwindSafe for ModularAgentEvent
impl Send for ModularAgentEvent
impl Sync for ModularAgentEvent
impl Unpin for ModularAgentEvent
impl UnsafeUnpin for ModularAgentEvent
impl UnwindSafe for ModularAgentEvent
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Source§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
Source§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
Source§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
Source§type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
Source§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
Source§impl<T> ConvUtil for T
impl<T> ConvUtil for T
Source§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
Source§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
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, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
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>
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>
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 moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more