Blame docs/src/request.rst

Packit Service 7c31a4
Packit Service 7c31a4
.. _request:
Packit Service 7c31a4
Packit Service 7c31a4
:c:type:`uv_req_t` --- Base request
Packit Service 7c31a4
===================================
Packit Service 7c31a4
Packit Service 7c31a4
`uv_req_t` is the base type for all libuv request types.
Packit Service 7c31a4
Packit Service 7c31a4
Structures are aligned so that any libuv request can be cast to `uv_req_t`.
Packit Service 7c31a4
All API functions defined here work with any request type.
Packit Service 7c31a4
Packit Service 7c31a4
Packit Service 7c31a4
Data types
Packit Service 7c31a4
----------
Packit Service 7c31a4
Packit Service 7c31a4
.. c:type:: uv_req_t
Packit Service 7c31a4
Packit Service 7c31a4
    The base libuv request structure.
Packit Service 7c31a4
Packit Service 7c31a4
.. c:type:: uv_any_req
Packit Service 7c31a4
Packit Service 7c31a4
    Union of all request types.
Packit Service 7c31a4
Packit Service 7c31a4
Packit Service 7c31a4
Public members
Packit Service 7c31a4
^^^^^^^^^^^^^^
Packit Service 7c31a4
Packit Service 7c31a4
.. c:member:: void* uv_req_t.data
Packit Service 7c31a4
Packit Service 7c31a4
    Space for user-defined arbitrary data. libuv does not use this field.
Packit Service 7c31a4
Packit Service 7c31a4
.. c:member:: uv_req_type uv_req_t.type
Packit Service 7c31a4
Packit Service 7c31a4
    Indicated the type of request. Readonly.
Packit Service 7c31a4
Packit Service 7c31a4
    ::
Packit Service 7c31a4
Packit Service 7c31a4
        typedef enum {
Packit Service 7c31a4
            UV_UNKNOWN_REQ = 0,
Packit Service 7c31a4
            UV_REQ,
Packit Service 7c31a4
            UV_CONNECT,
Packit Service 7c31a4
            UV_WRITE,
Packit Service 7c31a4
            UV_SHUTDOWN,
Packit Service 7c31a4
            UV_UDP_SEND,
Packit Service 7c31a4
            UV_FS,
Packit Service 7c31a4
            UV_WORK,
Packit Service 7c31a4
            UV_GETADDRINFO,
Packit Service 7c31a4
            UV_GETNAMEINFO,
Packit Service 7c31a4
            UV_REQ_TYPE_MAX,
Packit Service 7c31a4
        } uv_req_type;
Packit Service 7c31a4
Packit Service 7c31a4
Packit Service 7c31a4
API
Packit Service 7c31a4
---
Packit Service 7c31a4
Packit Service 7c31a4
.. c:function:: UV_REQ_TYPE_MAP(iter_macro)
Packit Service 7c31a4
Packit Service 7c31a4
    Macro that expands to a series of invocations of `iter_macro` for
Packit Service 7c31a4
    each of the request types. `iter_macro` is invoked with two
Packit Service 7c31a4
    arguments: the name of the `uv_req_type` element without the `UV_`
Packit Service 7c31a4
    prefix, and the name of the corresponding structure type without the
Packit Service 7c31a4
    `uv_` prefix and `_t` suffix.
Packit Service 7c31a4
Packit Service 7c31a4
.. c:function:: int uv_cancel(uv_req_t* req)
Packit Service 7c31a4
Packit Service 7c31a4
    Cancel a pending request. Fails if the request is executing or has finished
Packit Service 7c31a4
    executing.
Packit Service 7c31a4
Packit Service 7c31a4
    Returns 0 on success, or an error code < 0 on failure.
Packit Service 7c31a4
Packit Service 7c31a4
    Only cancellation of :c:type:`uv_fs_t`, :c:type:`uv_getaddrinfo_t`,
Packit Service 7c31a4
    :c:type:`uv_getnameinfo_t`, :c:type:`uv_random_t` and :c:type:`uv_work_t`
Packit Service 7c31a4
    requests is currently supported.
Packit Service 7c31a4
Packit Service 7c31a4
    Cancelled requests have their callbacks invoked some time in the future.
Packit Service 7c31a4
    It's **not** safe to free the memory associated with the request until the
Packit Service 7c31a4
    callback is called.
Packit Service 7c31a4
Packit Service 7c31a4
    Here is how cancellation is reported to the callback:
Packit Service 7c31a4
Packit Service 7c31a4
    * A :c:type:`uv_fs_t` request has its req->result field set to `UV_ECANCELED`.
Packit Service 7c31a4
Packit Service 7c31a4
    * A :c:type:`uv_work_t`, :c:type:`uv_getaddrinfo_t`,
Packit Service 7c31a4
      :c:type:`uv_getnameinfo_t` or :c:type:`uv_random_t` request has its
Packit Service 7c31a4
      callback invoked with status == `UV_ECANCELED`.
Packit Service 7c31a4
Packit Service 7c31a4
.. c:function:: size_t uv_req_size(uv_req_type type)
Packit Service 7c31a4
Packit Service 7c31a4
    Returns the size of the given request type. Useful for FFI binding writers
Packit Service 7c31a4
    who don't want to know the structure layout.
Packit Service 7c31a4
Packit Service 7c31a4
.. c:function:: void* uv_req_get_data(const uv_req_t* req)
Packit Service 7c31a4
Packit Service 7c31a4
    Returns `req->data`.
Packit Service 7c31a4
Packit Service 7c31a4
    .. versionadded:: 1.19.0
Packit Service 7c31a4
Packit Service 7c31a4
.. c:function:: void* uv_req_set_data(uv_req_t* req, void* data)
Packit Service 7c31a4
Packit Service 7c31a4
    Sets `req->data` to `data`.
Packit Service 7c31a4
Packit Service 7c31a4
    .. versionadded:: 1.19.0
Packit Service 7c31a4
Packit Service 7c31a4
.. c:function:: uv_req_type uv_req_get_type(const uv_req_t* req)
Packit Service 7c31a4
Packit Service 7c31a4
    Returns `req->type`.
Packit Service 7c31a4
Packit Service 7c31a4
    .. versionadded:: 1.19.0
Packit Service 7c31a4
Packit Service 7c31a4
.. c:function:: const char* uv_req_type_name(uv_req_type type)
Packit Service 7c31a4
Packit Service 7c31a4
    Returns the name for the equivalent struct for a given request type,
Packit Service 7c31a4
    e.g. `"connect"` (as in :c:type:`uv_connect_t`) for `UV_CONNECT`.
Packit Service 7c31a4
Packit Service 7c31a4
    If no such request type exists, this returns `NULL`.
Packit Service 7c31a4
Packit Service 7c31a4
    .. versionadded:: 1.19.0