Request

Struct Request 

Source
pub struct Request(/* private fields */);
Expand description

Request object.

Can be constructed from a HREQUEST handle only:

fn on_data_load(pnm: &mut SCN_LOAD_DATA) -> Option<LOAD_RESULT> {
  let mut rq = Request::from(pnm.request_id);
  // ...
}

Implementations§

Source§

impl Request

Source

pub fn succeeded(&mut self, status: u32, data: Option<&[u8]>) -> Result<()>

Mark the request as complete with status and optional data.

Source

pub fn failed(&mut self, status: u32, data: Option<&[u8]>) -> Result<()>

Mark the request as complete with failure.

Source

pub fn append_received_data(&mut self, data: &[u8]) -> Result<()>

Append a data chunk to the received data.

Source

pub fn get_received_data(&self) -> Result<Vec<u8>>

Get received (so far) data.

Source

pub fn url(&self) -> Result<String>

Get the URL of the request.

Source

pub fn content_url(&self) -> Result<String>

Get a real URL of the content (e.g., after possible redirection).

Source

pub fn method(&self) -> Result<REQUEST_METHOD>

Get the data type of the request.

Source

pub fn request_type(&self) -> Result<RESOURCE_TYPE>

Get the resource data type of the request.

Source

pub fn response_type(&self) -> Result<String>

Get the MIME type of the received data.

Source

pub fn set_response_type(&mut self, mime_type: &str) -> Result<()>

Set the MIME type of the received data.

Source

pub fn set_response_encoding(&mut self, encoding_type: &str) -> Result<()>

Set the data encoding for the received data.

Source

pub fn parameters(&self) -> Result<HashMap<String, String>>

Get the parameters of the request.

Source

pub fn request_headers(&self) -> Result<HashMap<String, String>>

Get the headers of the request.

Source

pub fn set_request_header(&mut self, name: &str, value: &str) -> Result<()>

Set request header (a single item).

Source

pub fn response_headers(&self) -> Result<HashMap<String, String>>

Get the headers of the response.

Source

pub fn set_response_header(&mut self, name: &str, value: &str) -> Result<()>

Set respone header (a single item).

Source

pub fn proxy(&self) -> Result<(String, u16)>

Get proxy host and port (if any).

Source

pub fn completion_status(&self) -> Result<(REQUEST_STATE, u32)>

Get the current completion status of the request.

Returns current state and HTTP response code.

Source

pub fn request_duration(&self) -> Result<Duration>

Get the execution duratiom of the request.

Source

pub fn request_time(&self) -> Result<(Duration, Duration)>

Get the execution started and ended time of the request, in milliseconds.

Trait Implementations§

Source§

impl Clone for Request

Copies the object.

All allocated objects are reference counted so copying is just a matter of increasing reference counts.

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Drop for Request

Destroy the object.

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl From<*mut _HREQUEST> for Request

Construct a Request object from HREQUEST handle.

Source§

fn from(hrq: HREQUEST) -> Request

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.