Enum intrepid_core::System
source · pub enum System<Status, State> {
Direct(Direct<Status, State>),
Dispatch(Dispatch<Status, State>),
Routed(Routed<Status, State>),
}Expand description
A system is a collection of actions that can be invoked as services.
Variants§
Direct(Direct<Status, State>)
An unordered system that invokes all actions.
Dispatch(Dispatch<Status, State>)
A system that routes frames to actions fully matching patterns.
Routed(Routed<Status, State>)
A system that routes frames to matching patterns.
Implementations§
source§impl<State> System<Open, State>
impl<State> System<Open, State>
sourcepub fn with_state(&self, state: State) -> System<Stateful<State>, State>
pub fn with_state(&self, state: State) -> System<Stateful<State>, State>
Transition to a stateful system with a given state.
source§impl System<Open, ()>
impl System<Open, ()>
sourcepub fn without_state(self) -> System<Stateless, ()>
pub fn without_state(self) -> System<Stateless, ()>
If we know that the state is empty, we know that we can transition to a stateless system. Transition to a stateless system.
sourcepub fn handle_frame(self, frame: Frame) -> FrameFuture ⓘ
pub fn handle_frame(self, frame: Frame) -> FrameFuture ⓘ
Call the system with a frame.
source§impl<State> System<Stateful<State>, State>
impl<State> System<Stateful<State>, State>
sourcepub async fn handle_frame(self, frame: Frame) -> Result<Frame>
pub async fn handle_frame(self, frame: Frame) -> Result<Frame>
Call the system with a frame.
source§impl System<Stateless, ()>
impl System<Stateless, ()>
sourcepub fn handle_frame(self, frame: Frame) -> FrameFuture ⓘ
pub fn handle_frame(self, frame: Frame) -> FrameFuture ⓘ
Call the system with a frame.
source§impl<Status, State> System<Status, State>
impl<Status, State> System<Status, State>
sourcepub fn on_frame<ActionHandler, Args>(self, action: ActionHandler) -> Self
pub fn on_frame<ActionHandler, Args>(self, action: ActionHandler) -> Self
Add a frame handler to the system. This is a no-op for systems that do not support wildcard routing or only support specific patterns.
sourcepub fn on<ActionHandler, Args>(
self,
pattern: impl AsRef<str>,
action: ActionHandler,
) -> Self
pub fn on<ActionHandler, Args>( self, pattern: impl AsRef<str>, action: ActionHandler, ) -> Self
Add a uri bound or path bound handler to the system.
- Dispatch systems will match the pattern exactly.
- Routed systems will match the pattern as a path fragment.
sourcepub fn action_context(&self) -> ActionContext<State>
pub fn action_context(&self) -> ActionContext<State>
Get the action context for this system.
Trait Implementations§
source§impl Handler<Frame, ()> for System<Stateless, ()>
impl Handler<Frame, ()> for System<Stateless, ()>
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>, _: ()) -> Self::Future
fn invoke(&self, frame: impl Into<Frame>, _: ()) -> 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<()>
fn context(&self) -> ActionContext<()>
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> Handler<Frame, State> for System<Open, State>
impl<State> Handler<Frame, State> for System<Open, 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> Handler<Frame, State> for System<Stateful<State>, State>
impl<State> Handler<Frame, State> for System<Stateful<State>, 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<IntoFrame> Service<IntoFrame> for System<Open, ()>
impl<IntoFrame> Service<IntoFrame> for System<Open, ()>
source§impl<State, IntoFrame> Service<IntoFrame> for System<Stateful<State>, State>
impl<State, IntoFrame> Service<IntoFrame> for System<Stateful<State>, State>
Auto Trait Implementations§
impl<Status, State> Freeze for System<Status, State>where
Status: Freeze,
impl<Status, State> !RefUnwindSafe for System<Status, State>
impl<Status, State> Send for System<Status, State>where
Status: Send,
impl<Status, State> Sync for System<Status, State>where
Status: Sync,
impl<Status, State> Unpin for System<Status, State>where
Status: Unpin,
impl<Status, State> !UnwindSafe for System<Status, State>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)source§impl<T, Request> ServiceExt<Request> for T
impl<T, Request> ServiceExt<Request> for T
source§fn ready(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
fn ready(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
Yields a mutable reference to the service when it is ready to accept a request.
source§fn ready_and(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
fn ready_and(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
👎Deprecated since 0.4.6: please use the
ServiceExt::ready method insteadYields a mutable reference to the service when it is ready to accept a request.
source§fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
Yields the service when it is ready to accept a request.
source§fn oneshot(self, req: Request) -> Oneshot<Self, Request>where
Self: Sized,
fn oneshot(self, req: Request) -> Oneshot<Self, Request>where
Self: Sized,
Consume this
Service, calling with the providing request once it is ready.source§fn and_then<F>(self, f: F) -> AndThen<Self, F>
fn and_then<F>(self, f: F) -> AndThen<Self, F>
Executes a new future after this service’s future resolves. This does
not alter the behaviour of the
poll_ready method. Read moresource§fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
Maps this service’s response value to a different value. This does not
alter the behaviour of the
poll_ready method. Read moresource§fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
Maps this service’s error value to a different value. This does not
alter the behaviour of the
poll_ready method. Read moresource§fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
Maps this service’s result type (
Result<Self::Response, Self::Error>)
to a different value, regardless of whether the future succeeds or
fails. Read moresource§fn map_request<F, NewRequest>(self, f: F) -> MapRequest<Self, F>
fn map_request<F, NewRequest>(self, f: F) -> MapRequest<Self, F>
Composes a function in front of the service. Read more
source§fn filter_async<F, NewRequest>(self, filter: F) -> AsyncFilter<Self, F>where
Self: Sized,
F: AsyncPredicate<NewRequest>,
fn filter_async<F, NewRequest>(self, filter: F) -> AsyncFilter<Self, F>where
Self: Sized,
F: AsyncPredicate<NewRequest>,
Composes this service with an
AsyncFilter that conditionally accepts or
rejects requests based on an [async predicate]. Read moresource§fn then<F, Response, Error, Fut>(self, f: F) -> Then<Self, F>
fn then<F, Response, Error, Fut>(self, f: F) -> Then<Self, F>
Composes an asynchronous function after this service. Read more
source§fn map_future<F, Fut, Response, Error>(self, f: F) -> MapFuture<Self, F>
fn map_future<F, Fut, Response, Error>(self, f: F) -> MapFuture<Self, F>
Composes a function that transforms futures produced by the service. Read more