pub struct Request(/* private fields */);
Expand description
The Request
sent to the server
Implementations§
Source§impl Request
impl Request
Sourcepub fn get(url: &str) -> RequestBuilder
pub fn get(url: &str) -> RequestBuilder
Creates a new GET
Request
with url.
Sourcepub fn post(url: &str) -> RequestBuilder
pub fn post(url: &str) -> RequestBuilder
Creates a new POST
Request
with url.
Sourcepub fn put(url: &str) -> RequestBuilder
pub fn put(url: &str) -> RequestBuilder
Creates a new PUT
Request
with url.
Sourcepub fn delete(url: &str) -> RequestBuilder
pub fn delete(url: &str) -> RequestBuilder
Creates a new DELETE
Request
with url.
Sourcepub fn patch(url: &str) -> RequestBuilder
pub fn patch(url: &str) -> RequestBuilder
Creates a new PATCH
Request
with url.
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 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 Request
impl RefUnwindSafe for Request
impl !Send for Request
impl !Sync for Request
impl Unpin for Request
impl UnwindSafe for Request
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.