pub struct HttpClient {}Expand description
An HTTP client interface.
Implementations§
Source§impl HttpClient
impl HttpClient
Sourcepub fn post_async(
url: &str,
json: &str,
timeout: f32,
callback: Box<dyn FnMut(Option<String>)>,
)
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.
Sourcepub fn post_with_headers_async(
url: &str,
headers: &Vec<&str>,
json: &str,
timeout: f32,
callback: Box<dyn FnMut(Option<String>)>,
)
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 formatkey: 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.
Sourcepub 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>)>,
)
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 formatkey: 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. Returnstrueto stop the request.callback- A callback function that is called when the request is complete. The function receives the response body as a parameter.
Sourcepub fn get_async(
url: &str,
timeout: f32,
callback: Box<dyn FnMut(Option<String>)>,
)
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.
Sourcepub fn download_async(
url: &str,
full_path: &str,
timeout: f32,
progress: Box<dyn FnMut(bool, i64, i64) -> bool>,
)
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) andtotal(the total number of bytes to be downloaded).
Auto Trait Implementations§
impl Freeze for HttpClient
impl RefUnwindSafe for HttpClient
impl Send for HttpClient
impl Sync for HttpClient
impl Unpin for HttpClient
impl UnwindSafe for HttpClient
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