use std::borrow::Cow;
#[cfg(feature = "blocking-stream")]
use nyquest_interface::blocking::{BoxedStream, SizedBodyStream, UnsizedBodyStream};
pub(crate) mod client;
#[cfg(feature = "blocking-stream")]
mod read_stream;
mod response;
#[cfg(not(feature = "blocking-stream"))]
type BoxedStream = std::convert::Infallible;
pub type Body = crate::body::Body<BoxedStream>;
pub type Request = crate::Request<BoxedStream>;
#[cfg(feature = "multipart")]
pub type Part = crate::body::Part<BoxedStream>;
#[cfg(feature = "multipart")]
pub type PartBody = crate::body::PartBody<BoxedStream>;
#[cfg(feature = "blocking-stream")]
pub use read_stream::ReadStream;
pub use response::Response;
#[cfg(feature = "blocking-stream")]
use crate::body::private::{IntoSizedStream, IntoUnsizedStream};
pub fn get(uri: impl Into<Cow<'static, str>>) -> crate::Result<Response> {
let client = crate::client::ClientBuilder::default().build_blocking()?;
client.request(Request::get(uri))
}
#[cfg(feature = "blocking-stream")]
impl<S: SizedBodyStream> IntoSizedStream<BoxedStream> for S {
fn into_stream(self, size: u64) -> BoxedStream {
BoxedStream::Sized {
stream: Box::new(self),
content_length: size,
}
}
}
#[cfg(feature = "blocking-stream")]
impl<S: UnsizedBodyStream> IntoUnsizedStream<BoxedStream> for S {
fn into_stream(self) -> BoxedStream {
BoxedStream::Unsized {
stream: Box::new(self),
}
}
}