Available on crate feature
ffi
and hyper_unstable_ffi
only.Expand description
§hyper C API
This part of the documentation describes the C API for hyper. That is, how to use the hyper library in C code. This is not a regular Rust module, and thus it is not accessible in Rust.
§Unstable
The C API of hyper is currently unstable, which means it’s not part of
the semver contract as the rest of the Rust API is. Because of that, it’s
only accessible if --cfg hyper_unstable_ffi
is passed to rustc
when
compiling. The easiest way to do that is setting the RUSTFLAGS
environment variable.
§Building
The C API is part of the Rust library, but isn’t compiled by default. Using
cargo
, staring with 1.64.0
, it can be compiled with the following command:
RUSTFLAGS="--cfg hyper_unstable_ffi" cargo rustc --crate-type cdylib --features client,http1,http2,ffi
Structs§
- A streaming HTTP body.
- A buffer of bytes that is sent or received on a
hyper_body
. - An HTTP client connection handle.
- An options builder to configure an HTTP client connection.
- An async context for a task that contains the related waker.
- A more detailed error object returned by some hyper functions.
- A task executor for
hyper_task
s. - An HTTP header map.
- A read/write handle for a specific connection.
- An HTTP request.
- An HTTP response.
- An async task.
- A waker that is saved and used to waken a pending task.
Enums§
- A return code for many of hyper’s methods.
- A descriptor for what type a
hyper_task
value is.
Constants§
- The HTTP/2 version.
- The HTTP/1.0 version.
- The HTTP/1.1 version.
- An HTTP Version that is unspecified.
- Sentinel value to return from a read or write callback that the operation has errored.
- Sentinel value to return from a read or write callback that the operation is pending.
- Return in iter functions to stop iterating.
- Return in iter functions to continue iterating.
- Return in a poll function indicate an error.
- Return in a poll function to indicate it is still pending.
- Return in a poll function to indicate it was ready.
Functions§
- Creates a task that will poll a response body for the next buffer of data.
- Creates a task to execute the callback with each body chunk received.
- Free a body.
- Creates a new “empty” body.
- Set the outgoing data callback for this body.
- Set userdata on this body, which will be passed to callback functions.
- Get a pointer to the bytes in this buffer.
- Create a new
hyper_buf *
by copying the provided bytes. - Free this buffer.
- Get the length of the bytes this buffer contains.
- Free a
hyper_clientconn *
. - Creates an HTTP client handshake task.
- Set the client background task executor.
- Free a set of HTTP clientconn options.
- Set whether to use HTTP2.
- Set whether HTTP/1 connections accept obsolete line folding for header values.
- Creates a new set of HTTP clientconn options to be used in a handshake.
- Set whether header case is preserved.
- Set whether header order is preserved.
- Creates a task to send a request on the client connection.
- Creates a waker associated with the task context.
- Get an equivalent
hyper_code
from this error. - Frees a
hyper_error
. - Print the details of this error to a buffer.
- Frees an executor and any incomplete tasks still part of it.
- Creates a new task executor.
- Polls the executor, trying to make progress on any tasks that can do so.
- Push a task onto the executor.
- Adds the provided value to the list of the provided name.
- Iterates the headers passing each name and value pair to the callback.
- Sets the header with the provided name to the provided value.
- Free an IO handle.
- Create a new IO type used to represent a transport.
- Set the read function for this IO transport.
- Set the user data pointer for this IO to some value.
- Set the write function for this IO transport.
- Free an HTTP request.
- Gets a mutable reference to the HTTP headers of this request
- Construct a new HTTP request.
- Set an informational (1xx) response callback.
- Set the body of the request.
- Set the HTTP Method of the request.
- Set the URI of the request.
- Set the URI of the request with separate scheme, authority, and path/query strings.
- Set the preferred HTTP version of the request.
- Take ownership of the body of this response.
- Free an HTTP response.
- Gets a reference to the HTTP headers of this response.
- Get a pointer to the reason-phrase of this response.
- Get the length of the reason-phrase of this response.
- Get the HTTP-Status code of this response.
- Get the HTTP version used by this response.
- Free a task.
- Set a user data pointer to be associated with this task.
- Query the return type of this task.
- Retrieve the userdata that has been set via
hyper_task_set_userdata
. - Takes the output value of this task.
- Returns a static ASCII (null terminated) string of the hyper version.
- Free a waker.
- Wake up the task associated with a waker.