Trait Body

Source
pub trait Body {
    type Error;

    // Required method
    fn poll_next(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>,
    ) -> Poll<Option<Result<Bytes, Self::Error>>>;

    // Provided method
    fn size_hint(&self) -> SizeHint { ... }
}
Expand description

请求或响应的正文特征。

Required Associated Types§

Source

type Error

正文产生的错误。

Required Methods§

Source

fn poll_next( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Option<Result<Bytes, Self::Error>>>

尝试提取正文的下一个数据,如果正文耗尽则返回None

Provided Methods§

Source

fn size_hint(&self) -> SizeHint

返回正文剩余长度的界限。

Implementations on Foreign Types§

Source§

impl Body for &'static str

Source§

type Error = Infallible

Source§

fn poll_next( self: Pin<&mut &'static str>, _: &mut Context<'_>, ) -> Poll<Option<Result<Bytes, <&'static str as Body>::Error>>>

Source§

fn size_hint(&self) -> SizeHint

Source§

impl Body for &'static [u8]

Source§

type Error = Infallible

Source§

fn poll_next( self: Pin<&mut &'static [u8]>, _: &mut Context<'_>, ) -> Poll<Option<Result<Bytes, <&'static [u8] as Body>::Error>>>

Source§

fn size_hint(&self) -> SizeHint

Source§

impl Body for Cow<'static, str>

Source§

type Error = Infallible

Source§

fn poll_next( self: Pin<&mut Cow<'static, str>>, cx: &mut Context<'_>, ) -> Poll<Option<Result<Bytes, <Cow<'static, str> as Body>::Error>>>

Source§

fn size_hint(&self) -> SizeHint

Source§

impl Body for Cow<'static, [u8]>

Source§

type Error = Infallible

Source§

fn poll_next( self: Pin<&mut Cow<'static, [u8]>>, cx: &mut Context<'_>, ) -> Poll<Option<Result<Bytes, <Cow<'static, [u8]> as Body>::Error>>>

Source§

fn size_hint(&self) -> SizeHint

Source§

impl Body for ()

Source§

type Error = Infallible

Source§

fn poll_next( self: Pin<&mut ()>, _: &mut Context<'_>, ) -> Poll<Option<Result<Bytes, <() as Body>::Error>>>

Source§

fn size_hint(&self) -> SizeHint

Source§

impl Body for String

Source§

impl Body for Vec<u8>

Source§

type Error = Infallible

Source§

fn poll_next( self: Pin<&mut Vec<u8>>, _: &mut Context<'_>, ) -> Poll<Option<Result<Bytes, <Vec<u8> as Body>::Error>>>

Source§

fn size_hint(&self) -> SizeHint

Source§

impl<B> Body for &mut B
where B: Body + Unpin + ?Sized,

Source§

type Error = <B as Body>::Error

Source§

fn poll_next( self: Pin<&mut &mut B>, cx: &mut Context<'_>, ) -> Poll<Option<Result<Bytes, <&mut B as Body>::Error>>>

Source§

fn size_hint(&self) -> SizeHint

Source§

impl<B> Body for Box<B>
where B: Body + Unpin + ?Sized,

Source§

type Error = <B as Body>::Error

Source§

fn poll_next( self: Pin<&mut Box<B>>, cx: &mut Context<'_>, ) -> Poll<Option<Result<Bytes, <Box<B> as Body>::Error>>>

Source§

fn size_hint(&self) -> SizeHint

Source§

impl<P> Body for Pin<P>
where P: DerefMut + Unpin, <P as Deref>::Target: Body,

Source§

type Error = <<P as Deref>::Target as Body>::Error

Source§

fn poll_next( self: Pin<&mut Pin<P>>, cx: &mut Context<'_>, ) -> Poll<Option<Result<Bytes, <Pin<P> as Body>::Error>>>

Source§

fn size_hint(&self) -> SizeHint

Implementors§

Source§

impl Body for BoxBody

Source§

type Error = Box<dyn Error>

Source§

impl Body for Bytes

Source§

impl<B> Body for Request<B>
where B: Body,

Source§

type Error = <B as Body>::Error

Source§

impl<B> Body for Response<B>
where B: Body,

Source§

type Error = <B as Body>::Error

Source§

impl<B, F, E> Body for MapErr<B, F>
where B: Body, F: FnMut(<B as Body>::Error) -> E,

Source§

type Error = E

Source§

impl<S> Body for StreamBody<S>
where S: TryStream, <S as TryStream>::Ok: Into<Bytes>,