[−][src]Struct fastly::body::Body
An HTTP body that can be read from, written to, or appended to another body.
The most efficient way to read and write the body is through the Read
, BufRead
, and Write
implementations.
Implementations
impl Body
[src]
pub fn new() -> Self
[src]
Get a new, empty HTTP body.
pub fn into_handle(mut self: Self) -> BodyHandleⓘNotable traits for BodyHandle
impl Read for BodyHandleimpl Write for BodyHandle
[src]
Notable traits for BodyHandle
impl Read for BodyHandleimpl Write for BodyHandle
Convert a Body
into a BodyHandle
.
pub fn into_bytes(self) -> Vec<u8>
[src]
Read the entirety of the body.
Note that this will involve copying and buffering the body, and so should only be used for convenience on small request bodies.
pub fn into_string(self) -> String
[src]
Read the entirety of the body into a String
, interpreting the bytes as UTF-8.
Note that this will involve copying and buffering the body, and so should only be used for convenience on small request bodies.
pub fn append(&mut self, other: Body)
[src]
Append another body onto the end of this body.
pub fn write_bytes(&mut self, bytes: &[u8]) -> usize
[src]
Write a slice of bytes to the end of this Body
.
This function returns the number of bytes written.
body.write_bytes(&[0, 1, 2, 3]);
pub fn write_str(&mut self, string: &str) -> usize
[src]
Write a string slice to the end of this Body
.
This function returns the number of bytes written.
body.write_str("woof woof");
Trait Implementations
impl BufRead for Body
[src]
pub fn fill_buf(&mut self) -> Result<&[u8]>
[src]
pub fn consume(&mut self, amt: usize)
[src]
pub fn read_until(
&mut self,
byte: u8,
buf: &mut Vec<u8, Global>
) -> Result<usize, Error>
1.0.0[src]
&mut self,
byte: u8,
buf: &mut Vec<u8, Global>
) -> Result<usize, Error>
pub fn read_line(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0[src]
pub fn split(self, byte: u8) -> Split<Self>
1.0.0[src]
pub fn lines(self) -> Lines<Self>
1.0.0[src]
impl From<&'_ [u8]> for Body
[src]
impl From<&'_ str> for Body
[src]
impl From<BodyHandle> for Body
[src]
pub fn from(handle: BodyHandle) -> Self
[src]
impl From<String> for Body
[src]
impl From<Vec<u8, Global>> for Body
[src]
impl Read for Body
[src]
pub fn read(&mut self, buf: &mut [u8]) -> Result<usize>
[src]
pub fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>
[src]
pub fn is_read_vectored(&self) -> bool
[src]
pub unsafe fn initializer(&self) -> Initializer
[src]
pub fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
1.0.0[src]
pub fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0[src]
pub fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
1.6.0[src]
pub fn by_ref(&mut self) -> &mut Self
1.0.0[src]
pub fn bytes(self) -> Bytes<Self>
1.0.0[src]
pub fn chain<R>(self, next: R) -> Chain<Self, R> where
R: Read,
1.0.0[src]
R: Read,
pub fn take(self, limit: u64) -> Take<Self>
1.0.0[src]
impl Write for Body
[src]
pub fn write(&mut self, buf: &[u8]) -> Result<usize>
[src]
pub fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize>
[src]
pub fn flush(&mut self) -> Result<()>
[src]
pub fn is_write_vectored(&self) -> bool
[src]
pub fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0[src]
pub fn write_all_vectored(
&mut self,
bufs: &mut [IoSlice<'_>]
) -> Result<(), Error>
[src]
&mut self,
bufs: &mut [IoSlice<'_>]
) -> Result<(), Error>
pub fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error>
1.0.0[src]
pub fn by_ref(&mut self) -> &mut Self
1.0.0[src]
Auto Trait Implementations
impl RefUnwindSafe for Body
[src]
impl Send for Body
[src]
impl Sync for Body
[src]
impl Unpin for Body
[src]
impl UnwindSafe for Body
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,