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§
Required Methods§
Provided Methods§
Sourcefn context(&self) -> ActionContext<State>
fn context(&self) -> ActionContext<State>
Poll for the action context. This is normally a service, but in some cases, it may be a frame handler or a router.
Sourcefn as_into_actionable(&self) -> BoxedAction<State>
fn as_into_actionable(&self) -> BoxedAction<State>
Convert this action into a type erased actionable service.
Sourcefn into_stream(
self,
state: State,
) -> (impl Stream<Item = Result<Frame>>, FrameOutbox)
fn into_stream( self, state: State, ) -> (impl Stream<Item = Result<Frame>>, FrameOutbox)
Use into_stream
to turn the action into a stream and a stream handle. See
[Actionable::into_stream
] for more information.
Sourcefn ready(self, state: State) -> ReadyAction<Self, Args, State>
fn ready(self, state: State) -> ReadyAction<Self, Args, State>
Use with_state
to turn the action into a stateful action, which can be used
as a tower::Service
.
Sourcefn candidate(self) -> CandidateAction<Self, Args, State>
fn candidate(self) -> CandidateAction<Self, Args, State>
Create a Candidate actionable from the action, with the given state. Candidates can be “suspended” by boxing them for later.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.