pub trait FromCall: Sized + Send {
// Required method
fn from_call<'async_trait>(
call: Call,
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
where Self: 'async_trait;
}Expand description
Extract a value by consuming the whole Call.
Because it takes the Call by value, a FromCall extractor may appear only
as the last handler argument. Body-consuming extractors (such as a JSON
body) implement this directly. Every FromCallParts type is automatically
a FromCall via a blanket impl, and Call itself is FromCall (so a
|c: Call| handler is just the last-argument case).
use churust_core::{Call, FromCall};
use http::{HeaderMap, Method};
use bytes::Bytes;
let c = Call::new(Method::GET, "/".parse().unwrap(), HeaderMap::new(), Bytes::new());
// `Call` is itself a `FromCall`:
let back = Call::from_call(c).await.unwrap();
assert_eq!(back.method(), &Method::GET);Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl FromCall for String
The raw request body as text.
impl FromCall for String
The raw request body as text.
Fails with 400 Bad Request if the body is not valid UTF-8. For bytes that
may not be text, extract Bytes instead.
Implementors§
impl FromCall for Call
The whole Call as the final argument (Ktor call-style base case).
NOTE: deliberately NOT FromCallParts — that would conflict with the
blanket impl above.
impl FromCall for Multipart
impl FromCall for MultipartStream
impl FromCall for Payload
impl<L, R> FromCall for Either<L, R>
impl<T: FromCallParts> FromCall for T
Any parts extractor can also be the final argument.
do_not_recommend: when a body extractor is wrongly placed in a leading
position, rustc would otherwise suggest implementing FromCallParts for it
— which is the one thing that must not happen, since it would let the body
be consumed twice.