pub trait RequestExt<'w, 's> {
// Required method
fn request<'a, P: ProvideOnce>(
&'a mut self,
request: P::Request,
provider: P,
) -> Series<'w, 's, 'a, P::Response, P::Streams>
where P::Request: 'static + Send + Sync,
P::Response: 'static + Send + Sync,
P::Streams: StreamPack;
// Provided methods
fn provide<'a, T: 'static + Send + Sync>(
&'a mut self,
value: T,
) -> Series<'w, 's, 'a, T, ()> { ... }
fn serve<'a, T: 'static + Send + Sync + Future>(
&'a mut self,
future: T,
) -> Series<'w, 's, 'a, T::Output, ()>
where T::Output: 'static + Send + Sync { ... }
}Expand description
Extensions for creating a series of execution by making a request to a provider or
serving a value. This is implemented for Commands.
Required Methods§
Sourcefn request<'a, P: ProvideOnce>(
&'a mut self,
request: P::Request,
provider: P,
) -> Series<'w, 's, 'a, P::Response, P::Streams>
fn request<'a, P: ProvideOnce>( &'a mut self, request: P::Request, provider: P, ) -> Series<'w, 's, 'a, P::Response, P::Streams>
Call this on Commands to begin creating a series.
A series is a one-time chain of requests where the output of each request feeds into the input of the next. You should end the series by taking the response, detaching the series, or using one of the other terminating operations mentioned in the chart. You can do a single request (instead of a chain) by just taking the response immediately after the first request.
use crossflow::{prelude::*, testing::*};
let mut context = TestingContext::minimal_plugins();
let mut promise = context.command(|commands| {
let service = commands.spawn_service(spawn_test_entities);
commands.request(5, service).take().response
});
context.run_while_pending(&mut promise);
assert!(promise.peek().is_available());Provided Methods§
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.