pub enum System<Status, State> {
Batch(Batch<Status, State>),
DispatchBatch(DispatchBatch<Status, State>),
Routed(Routed<Status, State>),
FirstMatch(FirstMatch<Status, State>),
}
Expand description
A system is a collection of actions that can be invoked as services.
Variants§
Batch(Batch<Status, State>)
An unordered system that invokes all actions.
DispatchBatch(DispatchBatch<Status, State>)
A system that routes frames to actions fully matching patterns.
Routed(Routed<Status, State>)
A system that routes frames to matching patterns.
FirstMatch(FirstMatch<Status, State>)
A system that invokes the first action that matches a frame.
Implementations§
Source§impl<State> System<Open, State>
impl<State> System<Open, State>
Sourcepub fn batch() -> Self
pub fn batch() -> Self
Create a new batch system. Batch systems invoke all actions with a frame, returning a Frame that contains a list of frames.
Sourcepub fn dispatch_batch() -> Self
pub fn dispatch_batch() -> Self
Create a new dispatched system that aggregates responses from all matching actions into a list. Dispatch systems match actions exactly using a full path.
Sourcepub fn routed() -> Self
pub fn routed() -> Self
Create a new routed system which aggregates responses from all matching actions. Routed systems match actions using a composed path fragment.
Sourcepub fn first_match() -> Self
pub fn first_match() -> Self
Create a new first match system.
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) -> StatelessSystem
pub fn without_state(self) -> StatelessSystem
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<State> Handler<Frame, State> for System<Open, State>
impl<State> Handler<Frame, State> for System<Open, State>
Source§type Future = FrameFuture
type Future = FrameFuture
Source§fn invoke(&self, frame: impl Into<Frame>, state: State) -> Self::Future
fn invoke(&self, frame: impl Into<Frame>, state: State) -> Self::Future
Source§fn context(&self) -> ActionContext<State>
fn context(&self) -> ActionContext<State>
Source§fn as_into_actionable(&self) -> BoxedAction<State>
fn as_into_actionable(&self) -> BoxedAction<State>
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)
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>
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>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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<M, S, Target, Request> MakeService<Target, Request> for M
impl<M, S, Target, Request> MakeService<Target, Request> for M
Source§fn poll_ready(
&mut self,
cx: &mut Context<'_>,
) -> Poll<Result<(), <M as MakeService<Target, Request>>::MakeError>>
fn poll_ready( &mut self, cx: &mut Context<'_>, ) -> Poll<Result<(), <M as MakeService<Target, Request>>::MakeError>>
Poll::Ready
when the factory is able to create more services. Read moreSource§fn make_service(
&mut self,
target: Target,
) -> <M as MakeService<Target, Request>>::Future
fn make_service( &mut self, target: Target, ) -> <M as MakeService<Target, Request>>::Future
Source§fn into_service(self) -> IntoService<Self, Request>where
Self: Sized,
fn into_service(self) -> IntoService<Self, Request>where
Self: Sized,
Source§fn as_service(&mut self) -> AsService<'_, Self, Request>where
Self: Sized,
fn as_service(&mut self) -> AsService<'_, Self, Request>where
Self: Sized,
Source§impl<S, R> ServiceExt<R> for Swhere
S: Service<R>,
impl<S, R> ServiceExt<R> for Swhere
S: Service<R>,
Source§fn into_make_service(self) -> IntoMakeService<S>
fn into_make_service(self) -> IntoMakeService<S>
MakeService
, that is a Service
whose
response is another service. Read moreSource§fn into_make_service_with_connect_info<C>(
self,
) -> IntoMakeServiceWithConnectInfo<S, C>
fn into_make_service_with_connect_info<C>( self, ) -> IntoMakeServiceWithConnectInfo<S, C>
MakeService
, that will store C
’s
associated ConnectInfo
in a request extension such that ConnectInfo
can extract it. Read moreSource§fn handle_error<F, T>(self, f: F) -> HandleError<Self, F, T>
fn handle_error<F, T>(self, f: F) -> HandleError<Self, F, T>
HandleError
, that will handle errors
by converting them into responses. Read moreSource§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,
Source§fn ready_and(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
fn ready_and(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
ServiceExt::ready
method insteadSource§fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
Source§fn oneshot(self, req: Request) -> Oneshot<Self, Request>where
Self: Sized,
fn oneshot(self, req: Request) -> Oneshot<Self, Request>where
Self: Sized,
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>
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>
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>
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>
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>
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>,
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>
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>
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,
Source§fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
Source§fn oneshot(self, req: Request) -> Oneshot<Self, Request>where
Self: Sized,
fn oneshot(self, req: Request) -> Oneshot<Self, Request>where
Self: Sized,
Service
, calling it with the provided 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>
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>
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>
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>
Result<Self::Response, Self::Error>
)
to a different value, regardless of whether the future succeeds or
fails. Read more