pub struct HttpClient { /* private fields */ }Expand description
HTTP client for network operations
§TLS crypto provider
When built with the reqwest feature, HttpClient::new auto-calls HttpClient::init,
which builds a reqwest::Client eagerly – this constructs rustls’ ClientConfig inside
.build() even for a client that never issues an HTTPS request. Since the workspace’s
reqwest dependency uses rustls-no-provider (no aws-lc-rs/ring bundled – see the
“PURE RUST BLOCKER (reqwest)” note in the workspace root Cargo.toml), this crate installs
the pure-Rust OxiTLS provider (oxitls-rustcrypto-provider, COOLJAPAN’s RUSTSEC-2026-0104-fixed
fork of the abandoned upstream rustls-rustcrypto 0.0.2-alpha, resolved under the
rustls-rustcrypto name) as the process-default rustls CryptoProvider automatically,
right before the first client is constructed – unless the application has already installed
a provider of its own. Applications that want a different provider (e.g. a C-linked
aws-lc-rs/ring one) simply call rustls::crypto::CryptoProvider::install_default(...)
before the first use of SciRS2 networking; an existing process default is never overridden.
Implementations§
Source§impl HttpClient
impl HttpClient
Sourcepub fn new(config: NetworkConfig) -> Self
pub fn new(config: NetworkConfig) -> Self
Create a new HTTP client with the given configuration
Sourcepub fn init(&mut self) -> Result<()>
pub fn init(&mut self) -> Result<()>
Initialize the HTTP client (creates underlying reqwest client)
Sourcepub async fn download<P: AsRef<Path>>(
&self,
url: &str,
localpath: P,
) -> Result<()>
pub async fn download<P: AsRef<Path>>( &self, url: &str, localpath: P, ) -> Result<()>
Download a file from URL to local path
Sourcepub async fn upload<P: AsRef<Path>>(
&self,
localpath: P,
url: &str,
) -> Result<()>
pub async fn upload<P: AsRef<Path>>( &self, localpath: P, url: &str, ) -> Result<()>
Upload a file from local path to URL
Sourcepub async fn request(
&self,
method: HttpMethod,
url: &str,
body: Option<&[u8]>,
) -> Result<HttpResponse>
pub async fn request( &self, method: HttpMethod, url: &str, body: Option<&[u8]>, ) -> Result<HttpResponse>
Make a custom HTTP request
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for HttpClient
impl !UnwindSafe for HttpClient
impl Freeze for HttpClient
impl Send for HttpClient
impl Sync for HttpClient
impl Unpin for HttpClient
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.