pub struct Route { /* private fields */ }Expand description
An intercepted network request that can be fulfilled, continued, or aborted.
When a request matches a route pattern, a Route is passed to the handler.
The handler must call one of fulfill(), continue_(), abort(), or fallback()
to resolve the request.
Implementations§
Source§impl Route
impl Route
Sourcepub async fn is_handled(&self) -> bool
pub async fn is_handled(&self) -> bool
Check if this route has been handled.
Sourcepub fn is_response_stage(&self) -> bool
pub fn is_response_stage(&self) -> bool
Check if this route is at the response stage.
Sourcepub fn response_status(&self) -> Option<u16>
pub fn response_status(&self) -> Option<u16>
Get the response status code (if at response stage).
Sourcepub fn response_headers(&self) -> Option<&[HeaderEntry]>
pub fn response_headers(&self) -> Option<&[HeaderEntry]>
Get the response headers (if at response stage).
Sourcepub async fn response_body(&self) -> Result<Option<Vec<u8>>, NetworkError>
pub async fn response_body(&self) -> Result<Option<Vec<u8>>, NetworkError>
Get the response body (if at response stage).
§Errors
Returns an error if not at response stage or body cannot be fetched.
Sourcepub fn fulfill(&self) -> FulfillBuilder<'_>
pub fn fulfill(&self) -> FulfillBuilder<'_>
Sourcepub fn continue_(&self) -> ContinueBuilder<'_>
pub fn continue_(&self) -> ContinueBuilder<'_>
Sourcepub async fn abort(&self) -> Result<(), NetworkError>
pub async fn abort(&self) -> Result<(), NetworkError>
Sourcepub async fn abort_with(&self, error: AbortError) -> Result<(), NetworkError>
pub async fn abort_with(&self, error: AbortError) -> Result<(), NetworkError>
Sourcepub async fn fallback(&self) -> Result<(), NetworkError>
pub async fn fallback(&self) -> Result<(), NetworkError>
Pass this request to the next matching route handler.
If no other handlers match, the request continues to the server.
§Errors
Returns an error if the fallback fails.
Sourcepub fn fetch(&self) -> FetchBuilder<'_>
pub fn fetch(&self) -> FetchBuilder<'_>
Sourcepub async fn fetch_with_timeout(
&self,
timeout: Duration,
) -> Result<FetchedResponse<'_>, NetworkError>
pub async fn fetch_with_timeout( &self, timeout: Duration, ) -> Result<FetchedResponse<'_>, NetworkError>
Fetch the response with a timeout.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Route
impl !RefUnwindSafe for Route
impl Send for Route
impl Sync for Route
impl Unpin for Route
impl !UnwindSafe for Route
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