pub struct Context<C> { /* private fields */ }Expand description
Implementations§
Source§impl<C> Context<C>
impl<C> Context<C>
Sourcepub fn new(request: Request, client: C) -> Self
pub fn new(request: Request, client: C) -> Self
Creates a standalone context, e.g. to test a handler.
It gets an empty queue of its own and no datasets; see
with_queue and
with_dataset.
Sourcepub fn with_queue(self, queue: &Queue) -> Self
pub fn with_queue(self, queue: &Queue) -> Self
Replaces the queue, binding it to the request.
Sourcepub fn with_dataset<T, D>(self, dataset: D) -> Self
pub fn with_dataset<T, D>(self, dataset: D) -> Self
Registers dataset for items of type T.
Sourcepub const fn request_mut(&mut self) -> &mut Request
pub const fn request_mut(&mut self) -> &mut Request
Returns the request mutably, e.g. to add headers before fetching.
Sourcepub const fn client_mut(&mut self) -> &mut C
pub const fn client_mut(&mut self) -> &mut C
Returns the client mutably.
Sourcepub fn into_parts(self) -> (Request, C)
pub fn into_parts(self) -> (Request, C)
Splits the context into its request and client.
Sourcepub async fn fetch(self) -> Result<Response>where
C: Client,
pub async fn fetch(self) -> Result<Response>where
C: Client,
Fetches the response for the request.
Links followed through the queue, including clones taken earlier, resolve against the URI the response was served from from then on.
§Errors
Returns an error if the client fails to fetch the response.
Trait Implementations§
Auto Trait Implementations§
impl<C> !Freeze for Context<C>
impl<C> !RefUnwindSafe for Context<C>
impl<C> !UnwindSafe for Context<C>
impl<C> Send for Context<C>where
C: Send,
impl<C> Sync for Context<C>where
C: Sync,
impl<C> Unpin for Context<C>where
C: Unpin,
impl<C> UnsafeUnpin for Context<C>where
C: UnsafeUnpin,
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