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§
- hyper_
body - A streaming HTTP body.
- hyper_
buf - A buffer of bytes that is sent or received on a
hyper_body
. - hyper_
clientconn - An HTTP client connection handle.
- hyper_
clientconn_ options - An options builder to configure an HTTP client connection.
- hyper_
context - An async context for a task that contains the related waker.
- hyper_
error - A more detailed error object returned by some hyper functions.
- hyper_
executor - A task executor for
hyper_task
s. - hyper_
headers - An HTTP header map.
- hyper_
io - A read/write handle for a specific connection.
- hyper_
request - An HTTP request.
- hyper_
response - An HTTP response.
- hyper_
task - An async task.
- hyper_
waker - A waker that is saved and used to waken a pending task.
Enums§
- hyper_
code - A return code for many of hyper’s methods.
- hyper_
task_ return_ type - A descriptor for what type a
hyper_task
value is.
Constants§
- HYPER_
HTTP_ VERSION_ 2 - The HTTP/2 version.
- HYPER_
HTTP_ VERSION_ 1_ 0 - The HTTP/1.0 version.
- HYPER_
HTTP_ VERSION_ 1_ 1 - The HTTP/1.1 version.
- HYPER_
HTTP_ VERSION_ NONE - An HTTP Version that is unspecified.
- HYPER_
IO_ ERROR - Sentinel value to return from a read or write callback that the operation has errored.
- HYPER_
IO_ PENDING - Sentinel value to return from a read or write callback that the operation is pending.
- HYPER_
ITER_ BREAK - Return in iter functions to stop iterating.
- HYPER_
ITER_ CONTINUE - Return in iter functions to continue iterating.
- HYPER_
POLL_ ERROR - Return in a poll function indicate an error.
- HYPER_
POLL_ PENDING - Return in a poll function to indicate it is still pending.
- HYPER_
POLL_ READY - Return in a poll function to indicate it was ready.
Functions§
- hyper_
body_ data - Creates a task that will poll a response body for the next buffer of data.
- hyper_
body_ foreach - Creates a task to execute the callback with each body chunk received.
- hyper_
body_ free - Free a body.
- hyper_
body_ new - Creates a new “empty” body.
- hyper_
body_ set_ data_ func - Set the outgoing data callback for this body.
- hyper_
body_ set_ userdata - Set userdata on this body, which will be passed to callback functions.
- hyper_
buf_ bytes - Get a pointer to the bytes in this buffer.
- hyper_
buf_ copy - Create a new
hyper_buf *
by copying the provided bytes. - hyper_
buf_ free - Free this buffer.
- hyper_
buf_ len - Get the length of the bytes this buffer contains.
- hyper_
clientconn_ free - Free a
hyper_clientconn *
. - hyper_
clientconn_ handshake - Creates an HTTP client handshake task.
- hyper_
clientconn_ options_ exec - Set the client background task executor.
- hyper_
clientconn_ options_ free - Free a set of HTTP clientconn options.
- hyper_
clientconn_ options_ http2 - Set whether to use HTTP2.
- hyper_
clientconn_ options_ http1_ allow_ multiline_ headers - Set whether HTTP/1 connections accept obsolete line folding for header values.
- hyper_
clientconn_ options_ new - Creates a new set of HTTP clientconn options to be used in a handshake.
- hyper_
clientconn_ options_ set_ preserve_ header_ case - Set whether header case is preserved.
- hyper_
clientconn_ options_ set_ preserve_ header_ order - Set whether header order is preserved.
- hyper_
clientconn_ send - Creates a task to send a request on the client connection.
- hyper_
context_ waker - Creates a waker associated with the task context.
- hyper_
error_ code - Get an equivalent
hyper_code
from this error. - hyper_
error_ free - Frees a
hyper_error
. - hyper_
error_ print - Print the details of this error to a buffer.
- hyper_
executor_ free - Frees an executor and any incomplete tasks still part of it.
- hyper_
executor_ new - Creates a new task executor.
- hyper_
executor_ poll - Polls the executor, trying to make progress on any tasks that can do so.
- hyper_
executor_ push - Push a task onto the executor.
- hyper_
headers_ add - Adds the provided value to the list of the provided name.
- hyper_
headers_ foreach - Iterates the headers passing each name and value pair to the callback.
- hyper_
headers_ set - Sets the header with the provided name to the provided value.
- hyper_
io_ free - Free an IO handle.
- hyper_
io_ new - Create a new IO type used to represent a transport.
- hyper_
io_ set_ read - Set the read function for this IO transport.
- hyper_
io_ set_ userdata - Set the user data pointer for this IO to some value.
- hyper_
io_ set_ write - Set the write function for this IO transport.
- hyper_
request_ free - Free an HTTP request.
- hyper_
request_ headers - Gets a mutable reference to the HTTP headers of this request
- hyper_
request_ new - Construct a new HTTP request.
- hyper_
request_ on_ informational - Set an informational (1xx) response callback.
- hyper_
request_ set_ body - Set the body of the request.
- hyper_
request_ set_ method - Set the HTTP Method of the request.
- hyper_
request_ set_ uri - Set the URI of the request.
- hyper_
request_ set_ uri_ parts - Set the URI of the request with separate scheme, authority, and path/query strings.
- hyper_
request_ set_ version - Set the preferred HTTP version of the request.
- hyper_
response_ body - Take ownership of the body of this response.
- hyper_
response_ free - Free an HTTP response.
- hyper_
response_ headers - Gets a reference to the HTTP headers of this response.
- hyper_
response_ reason_ phrase - Get a pointer to the reason-phrase of this response.
- hyper_
response_ reason_ phrase_ len - Get the length of the reason-phrase of this response.
- hyper_
response_ status - Get the HTTP-Status code of this response.
- hyper_
response_ version - Get the HTTP version used by this response.
- hyper_
task_ free - Free a task.
- hyper_
task_ set_ userdata - Set a user data pointer to be associated with this task.
- hyper_
task_ type - Query the return type of this task.
- hyper_
task_ userdata - Retrieve the userdata that has been set via
hyper_task_set_userdata
. - hyper_
task_ value - Takes the output value of this task.
- hyper_
version - Returns a static ASCII (null terminated) string of the hyper version.
- hyper_
waker_ free - Free a waker.
- hyper_
waker_ wake - Wake up the task associated with a waker.