pub struct BrowserRequest(/* private fields */);Expand description
A fetch request made in the browser.
Methods from Deref<Target = Request>§
Sourcepub fn body_used(&self) -> bool
pub fn body_used(&self) -> bool
Has the request body been consumed?
If true, then any future attempts to consume the body will error.
Sourcepub fn body(&self) -> Option<ReadableStream>
pub fn body(&self) -> Option<ReadableStream>
Gets the body.
Sourcepub async fn form_data(&self) -> Result<FormData, Error>
pub async fn form_data(&self) -> Result<FormData, Error>
Reads the request to completion, returning it as FormData.
Sourcepub async fn json<T>(&self) -> Result<T, Error>where
T: DeserializeOwned,
pub async fn json<T>(&self) -> Result<T, Error>where
T: DeserializeOwned,
Reads the request to completion, parsing it as JSON.
Sourcepub async fn binary(&self) -> Result<Vec<u8>, Error>
pub async fn binary(&self) -> Result<Vec<u8>, Error>
Gets the binary request
This works by obtaining the response as an ArrayBuffer, creating a Uint8Array from it
and then converting it to Vec<u8>
Sourcepub fn mode(&self) -> RequestMode
pub fn mode(&self) -> RequestMode
Return the read only mode for the request
Trait Implementations§
Source§impl<E> ClientReq<E> for BrowserRequestwhere
E: FromServerFnError,
impl<E> ClientReq<E> for BrowserRequestwhere
E: FromServerFnError,
Source§type FormData = BrowserFormData
type FormData = BrowserFormData
The type used for URL-encoded form data in this client.
Source§fn try_new_req_query(
path: &str,
content_type: &str,
accepts: &str,
query: &str,
method: Method,
) -> Result<BrowserRequest, E>
fn try_new_req_query( path: &str, content_type: &str, accepts: &str, query: &str, method: Method, ) -> Result<BrowserRequest, E>
Attempts to construct a new request with query parameters.
Source§fn try_new_req_text(
path: &str,
content_type: &str,
accepts: &str,
body: String,
method: Method,
) -> Result<BrowserRequest, E>
fn try_new_req_text( path: &str, content_type: &str, accepts: &str, body: String, method: Method, ) -> Result<BrowserRequest, E>
Attempts to construct a new request with a text body.
Source§fn try_new_req_bytes(
path: &str,
content_type: &str,
accepts: &str,
body: Bytes,
method: Method,
) -> Result<BrowserRequest, E>
fn try_new_req_bytes( path: &str, content_type: &str, accepts: &str, body: Bytes, method: Method, ) -> Result<BrowserRequest, E>
Attempts to construct a new request with a binary body.
Source§fn try_new_req_multipart(
path: &str,
accepts: &str,
body: <BrowserRequest as ClientReq<E>>::FormData,
method: Method,
) -> Result<BrowserRequest, E>
fn try_new_req_multipart( path: &str, accepts: &str, body: <BrowserRequest as ClientReq<E>>::FormData, method: Method, ) -> Result<BrowserRequest, E>
Attempts to construct a new request with a multipart body.
Source§fn try_new_req_form_data(
path: &str,
accepts: &str,
content_type: &str,
body: <BrowserRequest as ClientReq<E>>::FormData,
method: Method,
) -> Result<BrowserRequest, E>
fn try_new_req_form_data( path: &str, accepts: &str, content_type: &str, body: <BrowserRequest as ClientReq<E>>::FormData, method: Method, ) -> Result<BrowserRequest, E>
Attempts to construct a new request with form data as the body.
Source§fn try_new_req_streaming(
path: &str,
accepts: &str,
content_type: &str,
body: impl Stream<Item = Bytes> + 'static,
method: Method,
) -> Result<BrowserRequest, E>
fn try_new_req_streaming( path: &str, accepts: &str, content_type: &str, body: impl Stream<Item = Bytes> + 'static, method: Method, ) -> Result<BrowserRequest, E>
Attempts to construct a new request with a streaming body.
Source§fn try_new_get(
path: &str,
content_type: &str,
accepts: &str,
query: &str,
) -> Result<Self, E>
fn try_new_get( path: &str, content_type: &str, accepts: &str, query: &str, ) -> Result<Self, E>
Attempts to construct a new
GET request.Source§fn try_new_delete(
path: &str,
content_type: &str,
accepts: &str,
query: &str,
) -> Result<Self, E>
fn try_new_delete( path: &str, content_type: &str, accepts: &str, query: &str, ) -> Result<Self, E>
Attempts to construct a new
DELETE request.
Note: Browser support for DELETE requests without JS/WASM may be poor.
Consider using a POST request if functionality without JS/WASM is required.Source§fn try_new_post(
path: &str,
content_type: &str,
accepts: &str,
body: String,
) -> Result<Self, E>
fn try_new_post( path: &str, content_type: &str, accepts: &str, body: String, ) -> Result<Self, E>
Attempts to construct a new
POST request with a text body.Source§fn try_new_patch(
path: &str,
content_type: &str,
accepts: &str,
body: String,
) -> Result<Self, E>
fn try_new_patch( path: &str, content_type: &str, accepts: &str, body: String, ) -> Result<Self, E>
Attempts to construct a new
PATCH request with a text body.
Note: Browser support for PATCH requests without JS/WASM may be poor.
Consider using a POST request if functionality without JS/WASM is required.Source§fn try_new_put(
path: &str,
content_type: &str,
accepts: &str,
body: String,
) -> Result<Self, E>
fn try_new_put( path: &str, content_type: &str, accepts: &str, body: String, ) -> Result<Self, E>
Attempts to construct a new
PUT request with a text body.
Note: Browser support for PUT requests without JS/WASM may be poor.
Consider using a POST request if functionality without JS/WASM is required.Source§fn try_new_post_bytes(
path: &str,
content_type: &str,
accepts: &str,
body: Bytes,
) -> Result<Self, E>
fn try_new_post_bytes( path: &str, content_type: &str, accepts: &str, body: Bytes, ) -> Result<Self, E>
Attempts to construct a new
POST request with a binary body.Source§fn try_new_patch_bytes(
path: &str,
content_type: &str,
accepts: &str,
body: Bytes,
) -> Result<Self, E>
fn try_new_patch_bytes( path: &str, content_type: &str, accepts: &str, body: Bytes, ) -> Result<Self, E>
Attempts to construct a new
PATCH request with a binary body.
Note: Browser support for PATCH requests without JS/WASM may be poor.
Consider using a POST request if functionality without JS/WASM is required.Source§fn try_new_put_bytes(
path: &str,
content_type: &str,
accepts: &str,
body: Bytes,
) -> Result<Self, E>
fn try_new_put_bytes( path: &str, content_type: &str, accepts: &str, body: Bytes, ) -> Result<Self, E>
Attempts to construct a new
PUT request with a binary body.
Note: Browser support for PUT requests without JS/WASM may be poor.
Consider using a POST request if functionality without JS/WASM is required.Source§fn try_new_post_form_data(
path: &str,
accepts: &str,
content_type: &str,
body: Self::FormData,
) -> Result<Self, E>
fn try_new_post_form_data( path: &str, accepts: &str, content_type: &str, body: Self::FormData, ) -> Result<Self, E>
Attempts to construct a new
POST request with form data as the body.Source§fn try_new_patch_form_data(
path: &str,
accepts: &str,
content_type: &str,
body: Self::FormData,
) -> Result<Self, E>
fn try_new_patch_form_data( path: &str, accepts: &str, content_type: &str, body: Self::FormData, ) -> Result<Self, E>
Attempts to construct a new
PATCH request with form data as the body.
Note: Browser support for PATCH requests without JS/WASM may be poor.
Consider using a POST request if functionality without JS/WASM is required.Source§fn try_new_put_form_data(
path: &str,
accepts: &str,
content_type: &str,
body: Self::FormData,
) -> Result<Self, E>
fn try_new_put_form_data( path: &str, accepts: &str, content_type: &str, body: Self::FormData, ) -> Result<Self, E>
Attempts to construct a new
PUT request with form data as the body.
Note: Browser support for PUT requests without JS/WASM may be poor.
Consider using a POST request if functionality without JS/WASM is required.Source§fn try_new_post_multipart(
path: &str,
accepts: &str,
body: Self::FormData,
) -> Result<Self, E>
fn try_new_post_multipart( path: &str, accepts: &str, body: Self::FormData, ) -> Result<Self, E>
Attempts to construct a new
POST request with a multipart body.Source§fn try_new_patch_multipart(
path: &str,
accepts: &str,
body: Self::FormData,
) -> Result<Self, E>
fn try_new_patch_multipart( path: &str, accepts: &str, body: Self::FormData, ) -> Result<Self, E>
Attempts to construct a new
PATCH request with a multipart body.
Note: Browser support for PATCH requests without JS/WASM may be poor.
Consider using a POST request if functionality without JS/WASM is required.Source§fn try_new_put_multipart(
path: &str,
accepts: &str,
body: Self::FormData,
) -> Result<Self, E>
fn try_new_put_multipart( path: &str, accepts: &str, body: Self::FormData, ) -> Result<Self, E>
Attempts to construct a new
PUT request with a multipart body.
Note: Browser support for PUT requests without JS/WASM may be poor.
Consider using a POST request if functionality without JS/WASM is required.Source§fn try_new_post_streaming(
path: &str,
accepts: &str,
content_type: &str,
body: impl Stream<Item = Bytes> + Send + 'static,
) -> Result<Self, E>
fn try_new_post_streaming( path: &str, accepts: &str, content_type: &str, body: impl Stream<Item = Bytes> + Send + 'static, ) -> Result<Self, E>
Attempts to construct a new
POST request with a streaming body.Source§fn try_new_patch_streaming(
path: &str,
accepts: &str,
content_type: &str,
body: impl Stream<Item = Bytes> + Send + 'static,
) -> Result<Self, E>
fn try_new_patch_streaming( path: &str, accepts: &str, content_type: &str, body: impl Stream<Item = Bytes> + Send + 'static, ) -> Result<Self, E>
Attempts to construct a new
PATCH request with a streaming body.
Note: Browser support for PATCH requests without JS/WASM may be poor.
Consider using a POST request if functionality without JS/WASM is required.Source§fn try_new_put_streaming(
path: &str,
accepts: &str,
content_type: &str,
body: impl Stream<Item = Bytes> + Send + 'static,
) -> Result<Self, E>
fn try_new_put_streaming( path: &str, accepts: &str, content_type: &str, body: impl Stream<Item = Bytes> + Send + 'static, ) -> Result<Self, E>
Attempts to construct a new
PUT request with a streaming body.
Note: Browser support for PUT requests without JS/WASM may be poor.
Consider using a POST request if functionality without JS/WASM is required.Source§impl Debug for BrowserRequest
impl Debug for BrowserRequest
Source§impl Deref for BrowserRequest
impl Deref for BrowserRequest
Source§impl DerefMut for BrowserRequest
impl DerefMut for BrowserRequest
Source§impl From<BrowserRequest> for Request
impl From<BrowserRequest> for Request
Source§fn from(value: BrowserRequest) -> Request
fn from(value: BrowserRequest) -> Request
Converts to this type from the input type.
Source§impl From<BrowserRequest> for Request
impl From<BrowserRequest> for Request
Source§fn from(value: BrowserRequest) -> Request
fn from(value: BrowserRequest) -> Request
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for BrowserRequest
impl RefUnwindSafe for BrowserRequest
impl Send for BrowserRequest
impl Sync for BrowserRequest
impl Unpin for BrowserRequest
impl UnwindSafe for BrowserRequest
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> SerializableKey for T
impl<T> SerializableKey for T
Source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Borrows the value.
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Takes the value.