pub type StatefulSystem<State> = System<Stateful<State>, State>;Expand description
A system which knows a state that lines up with the actions it contains. It’s possible to create a stateful system from an open system, and it’s possible to transition to it from a stateless system, if that system is given a handler that requires state. However, it’s not possible to transition from a stateful system to a stateless system.
Aliased Type§
pub enum StatefulSystem<State> {
Batch(Batch<Stateful<State>, State>),
DispatchBatch(DispatchBatch<Stateful<State>, State>),
Routed(Routed<Stateful<State>, State>),
FirstMatch(FirstMatch<Stateful<State>, State>),
}Variants§
Batch(Batch<Stateful<State>, State>)
An unordered system that invokes all actions.
DispatchBatch(DispatchBatch<Stateful<State>, State>)
A system that routes frames to actions fully matching patterns.
Routed(Routed<Stateful<State>, State>)
A system that routes frames to matching patterns.
FirstMatch(FirstMatch<Stateful<State>, State>)
A system that invokes the first action that matches a frame.
Implementations§
Trait Implementations§
Source§impl<State> Handler<Frame, State> for StatefulSystem<State>
impl<State> Handler<Frame, State> for StatefulSystem<State>
Source§type Future = FrameFuture
type Future = FrameFuture
Action futures must resolve into an Frame of some kind.
Source§fn invoke(&self, frame: impl Into<Frame>, state: State) -> Self::Future
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.
Source§fn 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.
Source§fn as_into_actionable(&self) -> BoxedAction<State>
fn as_into_actionable(&self) -> BoxedAction<State>
Convert this action into a type erased actionable service.
Source§fn 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.Source§fn 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.Source§fn 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.
Source§impl<State, IntoFrame> Service<IntoFrame> for StatefulSystem<State>
impl<State, IntoFrame> Service<IntoFrame> for StatefulSystem<State>
Source§impl<State> Service<Request<Body>> for StatefulSystem<State>
impl<State> Service<Request<Body>> for StatefulSystem<State>
Source§type Error = Infallible
type Error = Infallible
Errors produced by the service.
Source§type Future = Pin<Box<dyn Future<Output = Result<<System<Stateful<State>, State> as Service<Request<Body>>>::Response, <System<Stateful<State>, State> as Service<Request<Body>>>::Error>> + Send>>
type Future = Pin<Box<dyn Future<Output = Result<<System<Stateful<State>, State> as Service<Request<Body>>>::Response, <System<Stateful<State>, State> as Service<Request<Body>>>::Error>> + Send>>
The future response value.