pub trait Net: MaybeSend + MaybeSync {
// Required methods
fn get_bytes<'life0, 'async_trait>(
&'life0 self,
url: Url,
headers: Option<Headers>,
) -> Pin<Box<dyn Future<Output = Result<Bytes, NetError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_range<'life0, 'async_trait>(
&'life0 self,
url: Url,
range: RangeSpec,
headers: Option<Headers>,
) -> Pin<Box<dyn Future<Output = Result<ByteStream, NetError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn head<'life0, 'async_trait>(
&'life0 self,
url: Url,
headers: Option<Headers>,
) -> Pin<Box<dyn Future<Output = Result<Headers, NetError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn stream<'life0, 'async_trait>(
&'life0 self,
url: Url,
headers: Option<Headers>,
) -> Pin<Box<dyn Future<Output = Result<ByteStream, NetError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
HTTP networking trait.
Single definition for both native and wasm32 targets.
On native: MaybeSend = Send, MaybeSync = Sync, futures are Send.
On wasm32: MaybeSend/MaybeSync are blanket-implemented (no-op), futures are !Send.
Required Methods§
Sourcefn get_bytes<'life0, 'async_trait>(
&'life0 self,
url: Url,
headers: Option<Headers>,
) -> Pin<Box<dyn Future<Output = Result<Bytes, NetError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_bytes<'life0, 'async_trait>(
&'life0 self,
url: Url,
headers: Option<Headers>,
) -> Pin<Box<dyn Future<Output = Result<Bytes, NetError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get all bytes from a URL
Sourcefn get_range<'life0, 'async_trait>(
&'life0 self,
url: Url,
range: RangeSpec,
headers: Option<Headers>,
) -> Pin<Box<dyn Future<Output = Result<ByteStream, NetError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_range<'life0, 'async_trait>(
&'life0 self,
url: Url,
range: RangeSpec,
headers: Option<Headers>,
) -> Pin<Box<dyn Future<Output = Result<ByteStream, NetError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get a range of bytes from a URL
Sourcefn head<'life0, 'async_trait>(
&'life0 self,
url: Url,
headers: Option<Headers>,
) -> Pin<Box<dyn Future<Output = Result<Headers, NetError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn head<'life0, 'async_trait>(
&'life0 self,
url: Url,
headers: Option<Headers>,
) -> Pin<Box<dyn Future<Output = Result<Headers, NetError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Perform a HEAD request.
This is intended for lightweight metadata probes (e.g. Content-Length,
Accept-Ranges, Content-Type). Implementations should return response headers.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".