Struct qiniu_http::AsyncRequestBody
source · pub struct AsyncRequestBody<'a>(_);
Available on crate feature
async
only.Expand description
异步 HTTP 请求体
Implementations§
source§impl<'a> AsyncRequestBody<'a>
impl<'a> AsyncRequestBody<'a>
sourcepub fn from_referenced_reader<T: AsyncRead + AsyncReset + Unpin + Debug + Send + Sync + 'a>(
reader: &'a mut T,
size: u64
) -> Self
pub fn from_referenced_reader<T: AsyncRead + AsyncReset + Unpin + Debug + Send + Sync + 'a>(
reader: &'a mut T,
size: u64
) -> Self
通过异步输入流的可变引用创建异步 HTTP 请求体
sourcepub fn from_referenced_bytes(bytes: &'a [u8]) -> Self
pub fn from_referenced_bytes(bytes: &'a [u8]) -> Self
通过二进制数据的引用创建异步 HTTP 请求体
sourcepub fn from_reader(
reader: impl AsyncRead + AsyncReset + Unpin + Debug + Send + Sync + 'static,
size: u64
) -> Self
pub fn from_reader(
reader: impl AsyncRead + AsyncReset + Unpin + Debug + Send + Sync + 'static,
size: u64
) -> Self
通过异步输入流创建异步 HTTP 请求体
sourcepub fn from_bytes(bytes: Vec<u8>) -> Self
pub fn from_bytes(bytes: Vec<u8>) -> Self
通过二进制数据创建异步 HTTP 请求体
Examples found in repository?
src/request.rs (line 906)
905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974
fn default() -> Self {
Self::from_bytes(Default::default())
}
}
impl AsyncRead for AsyncRequestBody<'_> {
fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context, buf: &mut [u8]) -> Poll<IoResult<usize>> {
match &mut self.as_mut().0 {
AsyncRequestBodyInner::ReaderRef { reader, .. } => {
pin!(reader);
reader.poll_read(cx, buf)
}
AsyncRequestBodyInner::BytesRef(bytes) => {
pin!(bytes);
bytes.poll_read(cx, buf)
}
AsyncRequestBodyInner::Owned(owned) => {
pin!(owned);
owned.poll_read(cx, buf)
}
}
}
}
impl AsyncReset for AsyncRequestBody<'_> {
#[inline]
fn reset(&mut self) -> BoxFuture<IoResult<()>> {
Box::pin(async move {
match &mut self.0 {
AsyncRequestBodyInner::ReaderRef { reader, .. } => reader.reset().await,
AsyncRequestBodyInner::BytesRef(bytes) => bytes.reset().await,
AsyncRequestBodyInner::Owned(owned) => owned.reset().await,
}
})
}
}
impl<'a> From<&'a mut AsyncRequestBody<'_>> for AsyncRequestBody<'a> {
#[inline]
fn from(body: &'a mut AsyncRequestBody<'_>) -> Self {
Self::from_referenced_reader(body, body.size())
}
}
impl<'a> From<&'a [u8]> for AsyncRequestBody<'a> {
#[inline]
fn from(body: &'a [u8]) -> Self {
Self::from_referenced_bytes(body)
}
}
impl<'a> From<&'a str> for AsyncRequestBody<'a> {
#[inline]
fn from(body: &'a str) -> Self {
Self::from_referenced_bytes(body.as_bytes())
}
}
impl From<Vec<u8>> for AsyncRequestBody<'_> {
#[inline]
fn from(body: Vec<u8>) -> Self {
Self::from_bytes(body)
}
}
impl From<String> for AsyncRequestBody<'_> {
#[inline]
fn from(body: String) -> Self {
Self::from_bytes(body.into_bytes())
}
Trait Implementations§
source§impl AsyncRead for AsyncRequestBody<'_>
impl AsyncRead for AsyncRequestBody<'_>
source§impl AsyncReset for AsyncRequestBody<'_>
impl AsyncReset for AsyncRequestBody<'_>
source§impl<'a> Debug for AsyncRequestBody<'a>
impl<'a> Debug for AsyncRequestBody<'a>
source§impl Default for AsyncRequestBody<'_>
impl Default for AsyncRequestBody<'_>
source§impl<'a> From<&'a [u8]> for AsyncRequestBody<'a>
impl<'a> From<&'a [u8]> for AsyncRequestBody<'a>
source§impl<'a> From<&'a mut AsyncRequestBody<'_>> for AsyncRequestBody<'a>
impl<'a> From<&'a mut AsyncRequestBody<'_>> for AsyncRequestBody<'a>
source§fn from(body: &'a mut AsyncRequestBody<'_>) -> Self
fn from(body: &'a mut AsyncRequestBody<'_>) -> Self
Converts to this type from the input type.
source§impl<'a> From<&'a str> for AsyncRequestBody<'a>
impl<'a> From<&'a str> for AsyncRequestBody<'a>
source§impl From<String> for AsyncRequestBody<'_>
impl From<String> for AsyncRequestBody<'_>
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for AsyncRequestBody<'a>
impl<'a> Send for AsyncRequestBody<'a>
impl<'a> Sync for AsyncRequestBody<'a>
impl<'a> Unpin for AsyncRequestBody<'a>
impl<'a> !UnwindSafe for AsyncRequestBody<'a>
Blanket Implementations§
source§impl<R> AsyncReadExt for Rwhere
R: AsyncRead + ?Sized,
impl<R> AsyncReadExt for Rwhere
R: AsyncRead + ?Sized,
source§fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadFuture<'a, Self>where
Self: Unpin,
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadFuture<'a, Self>where
Self: Unpin,
Reads some bytes from the byte stream. Read more
source§fn read_vectored<'a>(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectoredFuture<'a, Self>where
Self: Unpin,
fn read_vectored<'a>(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectoredFuture<'a, Self>where
Self: Unpin,
source§fn read_to_end<'a>(
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEndFuture<'a, Self>where
Self: Unpin,
fn read_to_end<'a>(
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEndFuture<'a, Self>where
Self: Unpin,
source§fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String
) -> ReadToStringFuture<'a, Self>where
Self: Unpin,
fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String
) -> ReadToStringFuture<'a, Self>where
Self: Unpin,
source§fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExactFuture<'a, Self>where
Self: Unpin,
fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExactFuture<'a, Self>where
Self: Unpin,
Reads the exact number of bytes required to fill
buf
. Read moresource§fn take(self, limit: u64) -> Take<Self>where
Self: Sized,
fn take(self, limit: u64) -> Take<Self>where
Self: Sized,
Creates an adapter which will read at most
limit
bytes from it. Read more