pub struct ASKit { /* private fields */ }Implementations§
Source§impl ASKit
impl ASKit
pub fn new() -> Self
Sourcepub fn init() -> Result<Self, AgentError>
pub fn init() -> Result<Self, AgentError>
Initialize ASKit.
Sourcepub async fn ready(&self) -> Result<(), AgentError>
pub async fn ready(&self) -> Result<(), AgentError>
Prepare ASKit to be ready.
Sourcepub fn register_agent_definiton(&self, def: AgentDefinition)
pub fn register_agent_definiton(&self, def: AgentDefinition)
Register an agent definition.
Sourcepub fn get_agent_definitions(&self) -> AgentDefinitions
pub fn get_agent_definitions(&self) -> AgentDefinitions
Get all agent definitions.
Sourcepub fn get_agent_definition(&self, def_name: &str) -> Option<AgentDefinition>
pub fn get_agent_definition(&self, def_name: &str) -> Option<AgentDefinition>
Get an agent definition by name.
Sourcepub fn get_agent_config_specs(&self, def_name: &str) -> Option<AgentConfigSpecs>
pub fn get_agent_config_specs(&self, def_name: &str) -> Option<AgentConfigSpecs>
Get the config specs of an agent definition by name.
Sourcepub async fn get_agent_spec(&self, agent_id: &str) -> Option<AgentSpec>
pub async fn get_agent_spec(&self, agent_id: &str) -> Option<AgentSpec>
Get the agent spec by id.
Sourcepub async fn update_agent_spec(
&self,
agent_id: &str,
value: &Value,
) -> Result<(), AgentError>
pub async fn update_agent_spec( &self, agent_id: &str, value: &Value, ) -> Result<(), AgentError>
Update the agent spec by id.
Sourcepub fn get_agent_stream_info(&self, id: &str) -> Option<AgentStreamInfo>
pub fn get_agent_stream_info(&self, id: &str) -> Option<AgentStreamInfo>
Get info of the agent stream by id.
Sourcepub fn get_agent_stream_infos(&self) -> Vec<AgentStreamInfo>
pub fn get_agent_stream_infos(&self) -> Vec<AgentStreamInfo>
Get infos of all agent streams.
Sourcepub async fn get_agent_stream_spec(&self, id: &str) -> Option<AgentStreamSpec>
pub async fn get_agent_stream_spec(&self, id: &str) -> Option<AgentStreamSpec>
Get the agent stream spec by id.
Sourcepub fn update_agent_stream_spec(
&self,
id: &str,
value: &Value,
) -> Result<(), AgentError>
pub fn update_agent_stream_spec( &self, id: &str, value: &Value, ) -> Result<(), AgentError>
Update the agent stream spec
Sourcepub fn new_agent_stream(&self, name: &str) -> Result<String, AgentError>
pub fn new_agent_stream(&self, name: &str) -> Result<String, AgentError>
Create a new agent stream with the given name. If the name already exists, a unique name will be generated by appending a number suffix. Returns the id of the new agent stream.
Sourcepub fn rename_agent_stream(
&self,
id: &str,
new_name: &str,
) -> Result<String, AgentError>
pub fn rename_agent_stream( &self, id: &str, new_name: &str, ) -> Result<String, AgentError>
Rename an existing agent stream.
Sourcepub fn unique_stream_name(&self, name: &str) -> String
pub fn unique_stream_name(&self, name: &str) -> String
Generate a unique stream name by appending a number suffix if needed.
Sourcepub fn add_agent_stream(
&self,
name: String,
spec: AgentStreamSpec,
) -> Result<String, AgentError>
pub fn add_agent_stream( &self, name: String, spec: AgentStreamSpec, ) -> Result<String, AgentError>
Add a new agent stream with the given name and spec, and returns the id of the new agent stream.
The ids of the given spec, including agents and channels, are changed to new unique ids.
Sourcepub async fn remove_agent_stream(&self, id: &str) -> Result<(), AgentError>
pub async fn remove_agent_stream(&self, id: &str) -> Result<(), AgentError>
Remove an agent stream by id.
Sourcepub async fn start_agent_stream(&self, id: &str) -> Result<(), AgentError>
pub async fn start_agent_stream(&self, id: &str) -> Result<(), AgentError>
Start an agent stream by id.
Sourcepub async fn stop_agent_stream(&self, id: &str) -> Result<(), AgentError>
pub async fn stop_agent_stream(&self, id: &str) -> Result<(), AgentError>
Stop an agent stream by id.
Sourcepub fn new_agent_spec(&self, def_name: &str) -> Result<AgentSpec, AgentError>
pub fn new_agent_spec(&self, def_name: &str) -> Result<AgentSpec, AgentError>
Create a new agent spec from the given agent definition name.
Sourcepub fn add_agent(
&self,
stream_id: String,
spec: AgentSpec,
) -> Result<String, AgentError>
pub fn add_agent( &self, stream_id: String, spec: AgentSpec, ) -> Result<String, AgentError>
Add an agent to the specified stream, and returns the id of the newly added agent.
Sourcepub fn get_agent(
&self,
agent_id: &str,
) -> Option<Arc<AsyncMutex<Box<dyn Agent>>>>
pub fn get_agent( &self, agent_id: &str, ) -> Option<Arc<AsyncMutex<Box<dyn Agent>>>>
Get the agent by id.
Sourcepub fn add_channel(
&self,
stream_id: &str,
channel: ChannelSpec,
) -> Result<(), AgentError>
pub fn add_channel( &self, stream_id: &str, channel: ChannelSpec, ) -> Result<(), AgentError>
Add a channel to the specified stream.
Sourcepub fn add_agents_and_channels(
&self,
stream_id: &str,
agents: &Vec<AgentSpec>,
channels: &Vec<ChannelSpec>,
) -> Result<(Vec<AgentSpec>, Vec<ChannelSpec>), AgentError>
pub fn add_agents_and_channels( &self, stream_id: &str, agents: &Vec<AgentSpec>, channels: &Vec<ChannelSpec>, ) -> Result<(Vec<AgentSpec>, Vec<ChannelSpec>), AgentError>
Add agents and channels to the specified stream.
The ids of the given agents and channels are changed to new unique ids. The agents are not started automatically, even if the stream is running.
Sourcepub async fn remove_agent(
&self,
stream_id: &str,
agent_id: &str,
) -> Result<(), AgentError>
pub async fn remove_agent( &self, stream_id: &str, agent_id: &str, ) -> Result<(), AgentError>
Remove an agent from the specified stream.
If the agent is running, it will be stopped first.
Sourcepub fn remove_channel(
&self,
stream_id: &str,
channel: &ChannelSpec,
) -> Result<(), AgentError>
pub fn remove_channel( &self, stream_id: &str, channel: &ChannelSpec, ) -> Result<(), AgentError>
Remove a channel from the specified stream.
Sourcepub async fn start_agent(&self, agent_id: &str) -> Result<(), AgentError>
pub async fn start_agent(&self, agent_id: &str) -> Result<(), AgentError>
Start an agent by id.
Sourcepub async fn stop_agent(&self, agent_id: &str) -> Result<(), AgentError>
pub async fn stop_agent(&self, agent_id: &str) -> Result<(), AgentError>
Stop an agent by id.
Sourcepub async fn set_agent_configs(
&self,
agent_id: String,
configs: AgentConfigs,
) -> Result<(), AgentError>
pub async fn set_agent_configs( &self, agent_id: String, configs: AgentConfigs, ) -> Result<(), AgentError>
Set configs for an agent by id.
Sourcepub fn get_global_configs(&self, def_name: &str) -> Option<AgentConfigs>
pub fn get_global_configs(&self, def_name: &str) -> Option<AgentConfigs>
Get global configs for the agent definition by name.
Sourcepub fn set_global_configs(&self, def_name: String, configs: AgentConfigs)
pub fn set_global_configs(&self, def_name: String, configs: AgentConfigs)
Set global configs for the agent definition by name.
Sourcepub fn get_global_configs_map(&self) -> AgentConfigsMap
pub fn get_global_configs_map(&self) -> AgentConfigsMap
Get the global configs map.
Sourcepub fn set_global_configs_map(&self, new_configs_map: AgentConfigsMap)
pub fn set_global_configs_map(&self, new_configs_map: AgentConfigsMap)
Set the global configs map.
Sourcepub async fn send_agent_out(
&self,
agent_id: String,
ctx: AgentContext,
pin: String,
value: AgentValue,
) -> Result<(), AgentError>
pub async fn send_agent_out( &self, agent_id: String, ctx: AgentContext, pin: String, value: AgentValue, ) -> Result<(), AgentError>
Send output from an agent. (Async version)
Sourcepub fn try_send_agent_out(
&self,
agent_id: String,
ctx: AgentContext,
pin: String,
value: AgentValue,
) -> Result<(), AgentError>
pub fn try_send_agent_out( &self, agent_id: String, ctx: AgentContext, pin: String, value: AgentValue, ) -> Result<(), AgentError>
Send output from an agent.
Sourcepub async fn write_board_value(
&self,
name: String,
value: AgentValue,
) -> Result<(), AgentError>
pub async fn write_board_value( &self, name: String, value: AgentValue, ) -> Result<(), AgentError>
Write a value to the board.
Sourcepub async fn write_var_value(
&self,
stream_id: &str,
name: &str,
value: AgentValue,
) -> Result<(), AgentError>
pub async fn write_var_value( &self, stream_id: &str, name: &str, value: AgentValue, ) -> Result<(), AgentError>
Write a value to the variable board.
Sourcepub fn subscribe(&self) -> Receiver<ASKitEvent>
pub fn subscribe(&self) -> Receiver<ASKitEvent>
Subscribe to all ASKit events.
Sourcepub fn subscribe_to_event<F, T>(&self, filter_map: F) -> UnboundedReceiver<T>
pub fn subscribe_to_event<F, T>(&self, filter_map: F) -> UnboundedReceiver<T>
Subscribe to a specific type of ASKitEvent.
It takes a closure that filters and maps the events, and returns an mpsc::UnboundedReceiver
that will receive only the successfully mapped events.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ASKit
impl RefUnwindSafe for ASKit
impl Send for ASKit
impl Sync for ASKit
impl Unpin for ASKit
impl UnwindSafe for ASKit
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