Struct fastly::handle::StreamingBodyHandle

source ·
pub struct StreamingBodyHandle { /* private fields */ }
Expand description

A low-level interface to a streaming HTTP body.

The interface to this type is very similar to BodyHandle, however it is write-only, and can only be created as a result of calling ResponseHandle::send_to_client() or RequestHandle::send_async_streaming().

This type implements 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.

A streaming body handle will be automatically aborted if it goes out of scope without calling finish().

Implementations§

source§

impl StreamingBodyHandle

source

pub fn finish(self) -> Result<(), HandleError>

Finish writing to a streaming body handle.

source

pub fn from_body_handle(body_handle: BodyHandle) -> Self

Make a streaming body handle from a non-streaming handle.

This should only be used when calling the raw ABI directly, and care should be taken not to reuse or alias handle values.

source

pub unsafe fn as_u32(&self) -> u32

Get the underlying representation of the handle.

This should only be used when calling the raw ABI directly, and care should be taken not to reuse or alias handle values.

source

pub fn into_u32(self) -> u32

Turn a handle into its representation without closing the underlying resource.

This should only be used when calling the raw ABI directly, and care should be taken not to reuse or alias handle values.

source

pub fn append(&mut self, other: BodyHandle)

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.

§Examples
let mut streaming_body = response_handle.stream_to_client(BodyHandle::new());
streaming_body.append(other_body);

Trait Implementations§

source§

impl Debug for StreamingBodyHandle

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<StreamingBodyHandle> for StreamingBody

source§

fn from(handle: StreamingBodyHandle) -> Self

Converts to this type from the input type.
source§

impl Hash for StreamingBodyHandle

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for StreamingBodyHandle

source§

fn eq(&self, other: &StreamingBodyHandle) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Write for StreamingBodyHandle

source§

fn write(&mut self, buf: &[u8]) -> Result<usize>

Write a buffer into this writer, returning how many bytes were written. Read more
source§

fn flush(&mut self) -> Result<()>

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
1.36.0 · source§

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>

Like write, except that it writes from a slice of buffers. Read more
source§

fn is_write_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Writer has an efficient write_vectored implementation. Read more
1.0.0 · source§

fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>

Attempts to write an entire buffer into this writer. Read more
source§

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>

🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
1.0.0 · source§

fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error>

Writes a formatted string into this writer, returning any error encountered. Read more
1.0.0 · source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adapter for this instance of Write. Read more
source§

impl Eq for StreamingBodyHandle

source§

impl StructuralPartialEq for StreamingBodyHandle

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.