StreamingBodyHandle

Structin handlefastly 0.13.1View source
pub struct StreamingBodyHandle { /* private fields */ }

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(), or as part of a CandidateResponse body transformation.

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().

Methods

fn abandon(self) -> Result<(), HandleError>

Abandon a streaming body handle, indicating an unsuccessful end of the stream.

Parameters

self: Self

Returns

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);

Parameters

self: &mut Self
other: BodyHandle
unsafe fn as_u32(&self) -> u32

Get the underlying representation of the handle.

Safety

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

Parameters

self: &Self

Returns

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

Finish writing to a streaming body handle.

Parameters

self: Self

Returns

from_body_handle

View source
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.

Parameters

body_handle: BodyHandle

Returns

Self

into_u32

View source
fn into_u32(self) -> u32

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

Safety

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

Parameters

self: Self

Returns

u32

Trait implementations

impl Debug for StreamingBodyHandle

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

Parameters

self: &Self
f: &mut $crate::fmt::Formatter

Returns

$crate::fmt::Result

impl Drop for StreamingBodyHandle

fn drop(&mut self)

Parameters

self: &mut Self

impl Hash for StreamingBodyHandle

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

Parameters

self: &Self
state: &mut __H

impl PartialEq for StreamingBodyHandle

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

Parameters

self: &Self
other: &Self

Returns

bool

impl Write for StreamingBodyHandle

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

Parameters

self: &mut Self

Returns

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

Parameters

self: &mut Self
buf: &[u8]

Returns

std::io::Result<usize>

Auto trait implementations

Blanket implementations