[−][src]Struct fastly::handle::BodyHandle
A low-level interface to HTTP bodies.
For most applications, you should use Body
instead of this
interface. See the top-level handle
documentation for more details.
This type implements Read
to read bytes from the beginning of a body, and Write
to write
to the end of a body. Note that these operations are unbuffered, unlike the same operations on
the higher-level Body
type.
Implementations
impl BodyHandle
[src]
pub const INVALID: Self
[src]
An invalid body handle.
This is primarily useful to represent uninitialized values when using the interfaces in
fastly_sys
.
pub fn is_valid(&self) -> bool
[src]
Returns true
if the body handle is valid.
pub fn is_invalid(&self) -> bool
[src]
Returns true
if the body handle is invalid.
pub fn from_client() -> Self
[src]
Get a handle to the client request body.
This handle may only be retrieved once per execution, either through this function or
through client_request_and_body()
.
pub fn new() -> Self
[src]
Acquire a new, empty body handle.
pub fn append(&mut self, other: BodyHandle)
[src]
Append another body onto the end of this body.
This operation is performed in amortized constant time, and so should always be preferred to reading an entire body and then writing the same contents to another body.
The other body will no longer be valid after this call.
pub fn into_bytes(self) -> Vec<u8>ⓘ
[src]
Read the entirety of the body into a byte vector.
Memory usage
This method will cause the entire body to be buffered in WebAssembly memory. You should take
care not to exceed the WebAssembly memory limits, and consider using Read
methods to
control how much of the body you process at once.
pub fn into_string(self) -> String
[src]
Read the entirety of the body into a String
, interpreting the bytes as UTF-8.
Memory usage
This method will cause the entire body to be buffered in WebAssembly memory. You should take
care not to exceed the WebAssembly memory limits, and consider using Read
methods to
control how much of the body you process at once.
Panics
If the body does not contain a valid UTF-8 string, this function will panic. To explicitly handle
the possibility of invalid UTF-8 data, use into_bytes()
and then convert
the bytes explicitly with a function like String::from_utf8
.
pub fn write_bytes(&mut self, bytes: &[u8]) -> usize
[src]
Write a slice of bytes to the end of this body, and return the number of bytes written.
Examples
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, and return the number of bytes written.
Examples
body.write_str("woof woof");
Trait Implementations
impl Debug for BodyHandle
[src]
impl Eq for BodyHandle
[src]
impl From<&'_ [u8]> for BodyHandle
[src]
impl From<&'_ str> for BodyHandle
[src]
impl From<BodyHandle> for Body
[src]
pub fn from(handle: BodyHandle) -> Self
[src]
impl From<String> for BodyHandle
[src]
impl From<Vec<u8, Global>> for BodyHandle
[src]
impl Hash for BodyHandle
[src]
pub fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<BodyHandle> for BodyHandle
[src]
pub fn eq(&self, other: &BodyHandle) -> bool
[src]
pub fn ne(&self, other: &BodyHandle) -> bool
[src]
impl Read for BodyHandle
[src]
pub fn read(&mut self, buf: &mut [u8]) -> Result<usize>
[src]
pub fn read_vectored(
&mut self,
bufs: &mut [IoSliceMut<'_>]
) -> Result<usize, Error>
1.36.0[src]
&mut self,
bufs: &mut [IoSliceMut<'_>]
) -> Result<usize, Error>
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 StructuralEq for BodyHandle
[src]
impl StructuralPartialEq for BodyHandle
[src]
impl Write for BodyHandle
[src]
pub fn write(&mut self, buf: &[u8]) -> Result<usize>
[src]
pub fn flush(&mut self) -> Result<()>
[src]
pub fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>
1.36.0[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 BodyHandle
[src]
impl Send for BodyHandle
[src]
impl Sync for BodyHandle
[src]
impl Unpin for BodyHandle
[src]
impl UnwindSafe for BodyHandle
[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>,