pub struct Request<T> {
pub data: T,
pub context: Context,
pub headers: Headers,
}Expand description
One incoming request, with its payload already parsed.
data is the handler’s own input type, checked before the handler runs — so
a payload that does not match is a typed failure with a code, reported from
the one place that knows what the handler expected.
Fields§
§data: TThe payload, parsed into the handler’s input type.
context: ContextThe execution context, as the host assembled it.
headers: HeadersThe request headers.
Implementations§
Source§impl<T> Request<T>
impl<T> Request<T>
Sourcepub fn new(data: T) -> Request<T>
pub fn new(data: T) -> Request<T>
A request carrying this payload and an empty context.
This is how a test calls a handler directly, with no host and no wasm:
use simpleplatform_sdk::prelude::*;
struct Input {
id: String,
}
fn handler(request: Request<Input>) -> Result<String, Error> {
Ok(request.data.id)
}
let answer = handler(Request::new(Input { id: "KNOW1".into() })).unwrap();
assert_eq!(answer, "KNOW1");Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Request<T>where
T: Freeze,
impl<T> RefUnwindSafe for Request<T>where
T: RefUnwindSafe,
impl<T> Send for Request<T>where
T: Send,
impl<T> Sync for Request<T>where
T: Sync,
impl<T> Unpin for Request<T>where
T: Unpin,
impl<T> UnsafeUnpin for Request<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Request<T>where
T: UnwindSafe,
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