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<CustErr> ClientReq<CustErr> for BrowserRequest
impl<CustErr> ClientReq<CustErr> for BrowserRequest
Source§type FormData = BrowserFormData
type FormData = BrowserFormData
The type used for URL-encoded form data in this client.
Source§fn try_new_get(
path: &str,
accepts: &str,
content_type: &str,
query: &str,
) -> Result<BrowserRequest, ServerFnError<CustErr>>
fn try_new_get( path: &str, accepts: &str, content_type: &str, query: &str, ) -> Result<BrowserRequest, ServerFnError<CustErr>>
Attempts to construct a new
GET
request.Source§fn try_new_post(
path: &str,
accepts: &str,
content_type: &str,
body: String,
) -> Result<BrowserRequest, ServerFnError<CustErr>>
fn try_new_post( path: &str, accepts: &str, content_type: &str, body: String, ) -> Result<BrowserRequest, ServerFnError<CustErr>>
Attempts to construct a new
POST
request with a text body.Source§fn try_new_post_bytes(
path: &str,
accepts: &str,
content_type: &str,
body: Bytes,
) -> Result<BrowserRequest, ServerFnError<CustErr>>
fn try_new_post_bytes( path: &str, accepts: &str, content_type: &str, body: Bytes, ) -> Result<BrowserRequest, ServerFnError<CustErr>>
Attempts to construct a new
POST
request with a binary body.Source§fn try_new_multipart(
path: &str,
accepts: &str,
body: <BrowserRequest as ClientReq<CustErr>>::FormData,
) -> Result<BrowserRequest, ServerFnError<CustErr>>
fn try_new_multipart( path: &str, accepts: &str, body: <BrowserRequest as ClientReq<CustErr>>::FormData, ) -> Result<BrowserRequest, ServerFnError<CustErr>>
Attempts to construct a new
POST
request with a multipart body.Source§fn try_new_post_form_data(
path: &str,
accepts: &str,
content_type: &str,
body: <BrowserRequest as ClientReq<CustErr>>::FormData,
) -> Result<BrowserRequest, ServerFnError<CustErr>>
fn try_new_post_form_data( path: &str, accepts: &str, content_type: &str, body: <BrowserRequest as ClientReq<CustErr>>::FormData, ) -> Result<BrowserRequest, ServerFnError<CustErr>>
Attempts to construct a new
POST
request with form data as the body.Source§fn try_new_streaming(
path: &str,
accepts: &str,
content_type: &str,
body: impl Stream<Item = Bytes> + 'static,
) -> Result<BrowserRequest, ServerFnError<CustErr>>
fn try_new_streaming( path: &str, accepts: &str, content_type: &str, body: impl Stream<Item = Bytes> + 'static, ) -> Result<BrowserRequest, ServerFnError<CustErr>>
Attempts to construct a new
POST
request with a streaming body.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.
Source§impl From<Request> for BrowserRequest
impl From<Request> for BrowserRequest
Source§fn from(value: Request) -> BrowserRequest
fn from(value: Request) -> BrowserRequest
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> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Source§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Create an instance of this type from an initialization function
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<Ret> SpawnIfAsync<(), Ret> for Ret
impl<Ret> SpawnIfAsync<(), Ret> for Ret
Source§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
Source§fn super_from(input: T) -> O
fn super_from(input: T) -> O
Convert from a type to another type.
Source§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
Source§fn super_into(self) -> O
fn super_into(self) -> O
Convert from a type to another type.