Trait intrepid_core::Handler

source ·
pub trait Handler<Args, State>: Clone {
    type Future: Future<Output = Result<Frame>> + Send + 'static;

    // Required method
    fn invoke(&self, frame: impl Into<Frame>, state: State) -> Self::Future;

    // Provided methods
    fn context(&self) -> ActionContext<State>
       where State: Send + Sync + 'static { ... }
    fn as_into_actionable(&self) -> BoxedAction<State>
       where Self: Clone + Send + Sync + 'static,
             Args: Clone + Send + Sync + 'static,
             State: Clone + Send + Sync + 'static { ... }
    fn into_stream(
        self,
        state: State,
    ) -> (impl Stream<Item = Result<Frame>>, FrameOutbox)
       where Self: Clone + Send + Sync + 'static,
             Args: Clone + Send + Sync + 'static,
             State: Clone + Send + Sync + 'static { ... }
    fn ready(self, state: State) -> ReadyAction<Self, Args, State>
       where Self: Clone + Send + 'static,
             Args: Clone + Send + 'static,
             State: Clone + Send + 'static { ... }
    fn candidate(self) -> CandidateAction<Self, Args, State>
       where Self: Clone + Send + 'static,
             Args: Clone + Send + 'static,
             State: Clone + Send + 'static { ... }
    fn active(self, state: State) -> ActiveAction
       where Self: Clone + Send + Sync + 'static,
             Args: Clone + Send + Sync + 'static,
             State: Clone + Send + Sync + 'static { ... }
}
Expand description

An action is an async function that can be turned into an frame handler.

Required Associated Types§

source

type Future: Future<Output = Result<Frame>> + Send + 'static

Action futures must resolve into an Frame of some kind.

Required Methods§

source

fn invoke(&self, frame: impl Into<Frame>, state: State) -> Self::Future

Invoke the action with a given frame and state, returning the frameual frame that will be produced by the action.

Provided Methods§

source

fn context(&self) -> ActionContext<State>
where State: Send + Sync + 'static,

Poll for the action context. This is normally a service, but in some cases, it may be a frame handler or a router.

source

fn as_into_actionable(&self) -> BoxedAction<State>
where Self: Clone + Send + Sync + 'static, Args: Clone + Send + Sync + 'static, State: Clone + Send + Sync + 'static,

Convert this action into a type erased actionable service.

source

fn into_stream( self, state: State, ) -> (impl Stream<Item = Result<Frame>>, FrameOutbox)
where Self: Clone + Send + Sync + 'static, Args: Clone + Send + Sync + 'static, State: Clone + Send + Sync + 'static,

Use into_stream to turn the action into a stream and a stream handle. See [Actionable::into_stream] for more information.

source

fn ready(self, state: State) -> ReadyAction<Self, Args, State>
where Self: Clone + Send + 'static, Args: Clone + Send + 'static, State: Clone + Send + 'static,

Use with_state to turn the action into a stateful action, which can be used as a tower::Service.

source

fn candidate(self) -> CandidateAction<Self, Args, State>
where Self: Clone + Send + 'static, Args: Clone + Send + 'static, State: Clone + Send + 'static,

Create a Candidate actionable from the action, with the given state. Candidates can be “suspended” by boxing them for later.

source

fn active(self, state: State) -> ActiveAction
where Self: Clone + Send + Sync + 'static, Args: Clone + Send + Sync + 'static, State: Clone + Send + Sync + 'static,

Create an Active actionable from the action, with the given state.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Handler<Frame, ()> for System<Stateless, ()>

source§

impl<Func, Future, State, Output> Handler<(), State> for Func
where Func: FnOnce() -> Future + Clone + Send + 'static, State: Send + Sync + 'static, Output: Into<Frame>, Future: Future<Output = Output> + Send + 'static,

source§

impl<Func, Future, State, Output, A> Handler<(A,), State> for Func
where Func: FnOnce(A) -> Future + Clone + Send + 'static, State: Send + Sync + 'static, Output: Into<Frame>, Future: Future<Output = Output> + Send + 'static, A: Extractor<State> + Send,

source§

impl<Func, Future, State, Output, A, B> Handler<(A, B), State> for Func
where Func: FnOnce(A, B) -> Future + Clone + Send + 'static, State: Send + Sync + 'static, Output: Into<Frame>, Future: Future<Output = Output> + Send + 'static, A: Extractor<State> + Send, B: Extractor<State> + Send,

source§

impl<Func, Future, State, Output, A, B, C> Handler<(A, B, C), State> for Func
where Func: FnOnce(A, B, C) -> Future + Clone + Send + 'static, State: Send + Sync + 'static, Output: Into<Frame>, Future: Future<Output = Output> + Send + 'static, A: Extractor<State> + Send, B: Extractor<State> + Send, C: Extractor<State> + Send,

source§

impl<Func, Future, State, Output, A, B, C, D> Handler<(A, B, C, D), State> for Func
where Func: FnOnce(A, B, C, D) -> Future + Clone + Send + 'static, State: Send + Sync + 'static, Output: Into<Frame>, Future: Future<Output = Output> + Send + 'static, A: Extractor<State> + Send, B: Extractor<State> + Send, C: Extractor<State> + Send, D: Extractor<State> + Send,

source§

impl<Func, Future, State, Output, A, B, C, D, E> Handler<(A, B, C, D, E), State> for Func
where Func: FnOnce(A, B, C, D, E) -> Future + Clone + Send + 'static, State: Send + Sync + 'static, Output: Into<Frame>, Future: Future<Output = Output> + Send + 'static, A: Extractor<State> + Send, B: Extractor<State> + Send, C: Extractor<State> + Send, D: Extractor<State> + Send, E: Extractor<State> + Send,

source§

impl<Func, Future, State, Output, A, B, C, D, E, F> Handler<(A, B, C, D, E, F), State> for Func
where Func: FnOnce(A, B, C, D, E, F) -> Future + Clone + Send + 'static, State: Send + Sync + 'static, Output: Into<Frame>, Future: Future<Output = Output> + Send + 'static, A: Extractor<State> + Send, B: Extractor<State> + Send, C: Extractor<State> + Send, D: Extractor<State> + Send, E: Extractor<State> + Send, F: Extractor<State> + Send,

source§

impl<Func, Future, State, Output, A, B, C, D, E, F, G> Handler<(A, B, C, D, E, F, G), State> for Func
where Func: FnOnce(A, B, C, D, E, F, G) -> Future + Clone + Send + 'static, State: Send + Sync + 'static, Output: Into<Frame>, Future: Future<Output = Output> + Send + 'static, A: Extractor<State> + Send, B: Extractor<State> + Send, C: Extractor<State> + Send, D: Extractor<State> + Send, E: Extractor<State> + Send, F: Extractor<State> + Send, G: Extractor<State> + Send,

source§

impl<Func, Future, State, Output, A, B, C, D, E, F, G, H> Handler<(A, B, C, D, E, F, G, H), State> for Func
where Func: FnOnce(A, B, C, D, E, F, G, H) -> Future + Clone + Send + 'static, State: Send + Sync + 'static, Output: Into<Frame>, Future: Future<Output = Output> + Send + 'static, A: Extractor<State> + Send, B: Extractor<State> + Send, C: Extractor<State> + Send, D: Extractor<State> + Send, E: Extractor<State> + Send, F: Extractor<State> + Send, G: Extractor<State> + Send, H: Extractor<State> + Send,

source§

impl<Func, Future, State, Output, A, B, C, D, E, F, G, H, I> Handler<(A, B, C, D, E, F, G, H, I), State> for Func
where Func: FnOnce(A, B, C, D, E, F, G, H, I) -> Future + Clone + Send + 'static, State: Send + Sync + 'static, Output: Into<Frame>, Future: Future<Output = Output> + Send + 'static, A: Extractor<State> + Send, B: Extractor<State> + Send, C: Extractor<State> + Send, D: Extractor<State> + Send, E: Extractor<State> + Send, F: Extractor<State> + Send, G: Extractor<State> + Send, H: Extractor<State> + Send, I: Extractor<State> + Send,

source§

impl<Func, Future, State, Output, A, B, C, D, E, F, G, H, I, J> Handler<(A, B, C, D, E, F, G, H, I, J), State> for Func
where Func: FnOnce(A, B, C, D, E, F, G, H, I, J) -> Future + Clone + Send + 'static, State: Send + Sync + 'static, Output: Into<Frame>, Future: Future<Output = Output> + Send + 'static, A: Extractor<State> + Send, B: Extractor<State> + Send, C: Extractor<State> + Send, D: Extractor<State> + Send, E: Extractor<State> + Send, F: Extractor<State> + Send, G: Extractor<State> + Send, H: Extractor<State> + Send, I: Extractor<State> + Send, J: Extractor<State> + Send,

source§

impl<Func, Future, State, Output, A, B, C, D, E, F, G, H, I, J, K> Handler<(A, B, C, D, E, F, G, H, I, J, K), State> for Func
where Func: FnOnce(A, B, C, D, E, F, G, H, I, J, K) -> Future + Clone + Send + 'static, State: Send + Sync + 'static, Output: Into<Frame>, Future: Future<Output = Output> + Send + 'static, A: Extractor<State> + Send, B: Extractor<State> + Send, C: Extractor<State> + Send, D: Extractor<State> + Send, E: Extractor<State> + Send, F: Extractor<State> + Send, G: Extractor<State> + Send, H: Extractor<State> + Send, I: Extractor<State> + Send, J: Extractor<State> + Send, K: Extractor<State> + Send,

source§

impl<Func, Future, State, Output, A, B, C, D, E, F, G, H, I, J, K, L> Handler<(A, B, C, D, E, F, G, H, I, J, K, L), State> for Func
where Func: FnOnce(A, B, C, D, E, F, G, H, I, J, K, L) -> Future + Clone + Send + 'static, State: Send + Sync + 'static, Output: Into<Frame>, Future: Future<Output = Output> + Send + 'static, A: Extractor<State> + Send, B: Extractor<State> + Send, C: Extractor<State> + Send, D: Extractor<State> + Send, E: Extractor<State> + Send, F: Extractor<State> + Send, G: Extractor<State> + Send, H: Extractor<State> + Send, I: Extractor<State> + Send, J: Extractor<State> + Send, K: Extractor<State> + Send, L: Extractor<State> + Send,

source§

impl<State> Handler<Frame, State> for System<Open, State>
where State: Clone + Send + Sync + 'static,

source§

impl<State> Handler<Frame, State> for System<Stateful<State>, State>
where State: Clone + Send + Sync + 'static,