HttpClient

Struct HttpClient 

Source
pub struct HttpClient {}
Expand description

An HTTP client interface.

Implementations§

Source§

impl HttpClient

Source

pub fn post_async( url: &str, json: &str, timeout: f32, callback: Box<dyn FnMut(Option<String>)>, )

Sends a POST request to the specified URL and returns the response body.

§Arguments
  • url - The URL to send the request to.
  • json - The JSON data to send in the request body.
  • timeout - The timeout in seconds for the request.
  • callback - A callback function that is called when the request is complete. The function receives the response body as a parameter.
Source

pub fn post_with_headers_async( url: &str, headers: &Vec<&str>, json: &str, timeout: f32, callback: Box<dyn FnMut(Option<String>)>, )

Sends a POST request to the specified URL with custom headers and returns the response body.

§Arguments
  • url - The URL to send the request to.
  • headers - A vector of headers to include in the request. Each header should be in the format key: value.
  • json - The JSON data to send in the request body.
  • timeout - The timeout in seconds for the request.
  • callback - A callback function that is called when the request is complete. The function receives the response body as a parameter.
Source

pub fn post_with_headers_part_async( url: &str, headers: &Vec<&str>, json: &str, timeout: f32, part_callback: Box<dyn FnMut(&str) -> bool>, callback: Box<dyn FnMut(Option<String>)>, )

Sends a POST request to the specified URL with custom headers and returns the response body.

§Arguments
  • url - The URL to send the request to.
  • headers - A vector of headers to include in the request. Each header should be in the format key: value.
  • json - The JSON data to send in the request body.
  • timeout - The timeout in seconds for the request.
  • part_callback - A callback function that is called periodically to get part of the response content. Returns true to stop the request.
  • callback - A callback function that is called when the request is complete. The function receives the response body as a parameter.
Source

pub fn get_async( url: &str, timeout: f32, callback: Box<dyn FnMut(Option<String>)>, )

Sends a GET request to the specified URL and returns the response body.

§Arguments
  • url - The URL to send the request to.
  • timeout - The timeout in seconds for the request.
  • callback - A callback function that is called when the request is complete. The function receives the response body as a parameter.
Source

pub fn download_async( url: &str, full_path: &str, timeout: f32, progress: Box<dyn FnMut(bool, i64, i64) -> bool>, )

Downloads a file asynchronously from the specified URL and saves it to the specified path.

§Arguments
  • url - The URL of the file to download.
  • full_path - The full path where the downloaded file should be saved.
  • timeout - The timeout in seconds for the request.
  • progress - A callback function that is called periodically to report the download progress. The function receives three parameters: interrupted (a boolean value indicating whether the download was interrupted), current (the number of bytes downloaded so far) and total (the total number of bytes to be downloaded).

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> 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, 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.