pub struct SyncRequestBody<'a>(_);
Expand description

HTTP 请求体

Implementations§

通过输入流的可变引用创建 HTTP 请求体

Examples found in repository?
src/request.rs (line 719)
718
719
720
        fn from(body: &'a mut RequestBody<'_>) -> Self {
            Self::from_referenced_reader(body, body.size())
        }

通过二进制数据的引用创建 HTTP 请求体

Examples found in repository?
src/request.rs (line 726)
725
726
727
728
729
730
731
732
733
734
        fn from(body: &'a [u8]) -> Self {
            Self::from_referenced_bytes(body)
        }
    }

    impl<'a> From<&'a str> for RequestBody<'a> {
        #[inline]
        fn from(body: &'a str) -> Self {
            Self::from_referenced_bytes(body.as_bytes())
        }

通过输入流创建 HTTP 请求体

通过二进制数据创建 HTTP 请求体

Examples found in repository?
src/request.rs (line 690)
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
        fn default() -> Self {
            Self::from_bytes(Default::default())
        }
    }

    impl Read for RequestBody<'_> {
        #[inline]
        fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> {
            match &mut self.0 {
                RequestBodyInner::ReaderRef { reader, .. } => reader.read(buf),
                RequestBodyInner::BytesRef(bytes) => bytes.read(buf),
                RequestBodyInner::Owned(owned) => owned.read(buf),
            }
        }
    }

    impl Reset for RequestBody<'_> {
        #[inline]
        fn reset(&mut self) -> IoResult<()> {
            match &mut self.0 {
                RequestBodyInner::ReaderRef { reader, .. } => reader.reset(),
                RequestBodyInner::BytesRef(bytes) => bytes.reset(),
                RequestBodyInner::Owned(owned) => owned.reset(),
            }
        }
    }

    impl<'a> From<&'a mut RequestBody<'_>> for RequestBody<'a> {
        #[inline]
        fn from(body: &'a mut RequestBody<'_>) -> Self {
            Self::from_referenced_reader(body, body.size())
        }
    }

    impl<'a> From<&'a [u8]> for RequestBody<'a> {
        #[inline]
        fn from(body: &'a [u8]) -> Self {
            Self::from_referenced_bytes(body)
        }
    }

    impl<'a> From<&'a str> for RequestBody<'a> {
        #[inline]
        fn from(body: &'a str) -> Self {
            Self::from_referenced_bytes(body.as_bytes())
        }
    }

    impl From<Vec<u8>> for RequestBody<'_> {
        #[inline]
        fn from(body: Vec<u8>) -> Self {
            Self::from_bytes(body)
        }
    }

    impl From<String> for RequestBody<'_> {
        #[inline]
        fn from(body: String) -> Self {
            Self::from_bytes(body.into_bytes())
        }

获取请求体大小

单位为字节

Examples found in repository?
src/request.rs (line 719)
718
719
720
        fn from(body: &'a mut RequestBody<'_>) -> Self {
            Self::from_referenced_reader(body, body.size())
        }

Trait Implementations§

Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Like read, except that it reads into a slice of buffers. Read more
🔬This is a nightly-only experimental API. (can_vector)
Determines if this Reader has an efficient read_vectored implementation. Read more
Read all bytes until EOF in this source, placing them into buf. Read more
Read all bytes until EOF in this source, appending them to buf. Read more
Read the exact number of bytes required to fill buf. Read more
🔬This is a nightly-only experimental API. (read_buf)
Pull some bytes from this source into the specified buffer. Read more
🔬This is a nightly-only experimental API. (read_buf)
Read the exact number of bytes required to fill cursor. Read more
Creates a “by reference” adaptor for this instance of Read. Read more
Transforms this Read instance to an Iterator over its bytes. Read more
Creates an adapter which will chain this stream with another. Read more
Creates an adapter which will read at most limit bytes from it. Read more
重置输入流 Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.