pub struct ActionBuilder<F, P, V, S, Q = String, CF = fn(Q, V, AgentState<S>) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + Sync>>> { /* private fields */ }Expand description
A builder to create actions from async functions with typed parameters F: The handler function type P: Input parameters for the handler S: State type Q: Output type from handler and input type for confirm handler CF: Confirm handler function type (defaults to EmptyConfirmHandler)
Implementations§
Source§impl<F, CF, P, Q, S, V, Fut, CFut> ActionBuilder<F, P, V, S, Q, CF>where
F: Fn(P, V, AgentState<S>) -> Fut + Send + Sync + Clone + 'static,
Fut: Future<Output = Result<Q, String>> + Send + Sync + 'static,
P: DeserializeOwned + Send + 'static,
CF: Fn(Q, V, AgentState<S>) -> CFut + Send + Sync + Clone + 'static,
CFut: Future<Output = Result<String, String>> + Send + Sync + 'static,
Q: Serialize + DeserializeOwned + Send + 'static,
S: Send + Sync + Clone + 'static,
V: Serialize + DeserializeOwned + Send + 'static,
impl<F, CF, P, Q, S, V, Fut, CFut> ActionBuilder<F, P, V, S, Q, CF>where
F: Fn(P, V, AgentState<S>) -> Fut + Send + Sync + Clone + 'static,
Fut: Future<Output = Result<Q, String>> + Send + Sync + 'static,
P: DeserializeOwned + Send + 'static,
CF: Fn(Q, V, AgentState<S>) -> CFut + Send + Sync + Clone + 'static,
CFut: Future<Output = Result<String, String>> + Send + Sync + 'static,
Q: Serialize + DeserializeOwned + Send + 'static,
S: Send + Sync + Clone + 'static,
V: Serialize + DeserializeOwned + Send + 'static,
pub fn new( name: impl Into<String>, handler: F, confirm_handler: Option<CF>, ) -> Self
pub fn description(self, description: impl Into<String>) -> Self
pub fn parameter( self, name: impl Into<String>, description: impl Into<String>, param_type: impl Into<String>, required: bool, ) -> Self
pub fn build(self) -> FunctionAction<S>
Auto Trait Implementations§
impl<F, P, V, S, Q, CF> Freeze for ActionBuilder<F, P, V, S, Q, CF>
impl<F, P, V, S, Q, CF> RefUnwindSafe for ActionBuilder<F, P, V, S, Q, CF>where
F: RefUnwindSafe,
CF: RefUnwindSafe,
P: RefUnwindSafe,
Q: RefUnwindSafe,
S: RefUnwindSafe,
V: RefUnwindSafe,
impl<F, P, V, S, Q, CF> Send for ActionBuilder<F, P, V, S, Q, CF>
impl<F, P, V, S, Q, CF> Sync for ActionBuilder<F, P, V, S, Q, CF>
impl<F, P, V, S, Q, CF> Unpin for ActionBuilder<F, P, V, S, Q, CF>
impl<F, P, V, S, Q, CF> UnwindSafe for ActionBuilder<F, P, V, S, Q, CF>
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