Struct fastly::handle::BodyHandle[][src]

#[repr(transparent)]
pub struct BodyHandle { /* fields omitted */ }
Expand description

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

An invalid body handle.

This is primarily useful to represent uninitialized values when using the interfaces in fastly_sys.

Returns true if the body handle is valid.

Returns true if the body handle is invalid.

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

Acquire a new, empty body handle.

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.

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.

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.

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

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

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Feeds this value into the given Hasher. Read more

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

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

🔬 This is a nightly-only experimental API. (read_initializer)

Determines if this Reader can work with buffers of uninitialized memory. 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

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 adaptor which will chain this stream with another. Read more

Creates an adaptor which will read at most limit bytes from it. Read more

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

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

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

🔬 This is a nightly-only experimental API. (can_vector)

Determines if this Writer has an efficient write_vectored implementation. Read more

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

🔬 This is a nightly-only experimental API. (write_all_vectored)

Attempts to write multiple buffers into this writer. Read more

Writes a formatted string into this writer, returning any error encountered. Read more

Creates a “by reference” adaptor for this instance of Write. 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

Performs the conversion.

Performs the conversion.

Should always be Self

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.