10e552da7Schristos 20e552da7Schristos.. _request: 30e552da7Schristos 40e552da7Schristos:c:type:`uv_req_t` --- Base request 50e552da7Schristos=================================== 60e552da7Schristos 70e552da7Schristos`uv_req_t` is the base type for all libuv request types. 80e552da7Schristos 90e552da7SchristosStructures are aligned so that any libuv request can be cast to `uv_req_t`. 100e552da7SchristosAll API functions defined here work with any request type. 110e552da7Schristos 120e552da7Schristos 130e552da7SchristosData types 140e552da7Schristos---------- 150e552da7Schristos 160e552da7Schristos.. c:type:: uv_req_t 170e552da7Schristos 180e552da7Schristos The base libuv request structure. 190e552da7Schristos 200e552da7Schristos.. c:type:: uv_any_req 210e552da7Schristos 220e552da7Schristos Union of all request types. 230e552da7Schristos 240e552da7Schristos 250e552da7SchristosPublic members 260e552da7Schristos^^^^^^^^^^^^^^ 270e552da7Schristos 280e552da7Schristos.. c:member:: void* uv_req_t.data 290e552da7Schristos 300e552da7Schristos Space for user-defined arbitrary data. libuv does not use this field. 310e552da7Schristos 320e552da7Schristos.. c:member:: uv_req_type uv_req_t.type 330e552da7Schristos 340e552da7Schristos Indicated the type of request. Readonly. 350e552da7Schristos 360e552da7Schristos :: 370e552da7Schristos 380e552da7Schristos typedef enum { 390e552da7Schristos UV_UNKNOWN_REQ = 0, 400e552da7Schristos UV_REQ, 410e552da7Schristos UV_CONNECT, 420e552da7Schristos UV_WRITE, 430e552da7Schristos UV_SHUTDOWN, 440e552da7Schristos UV_UDP_SEND, 450e552da7Schristos UV_FS, 460e552da7Schristos UV_WORK, 470e552da7Schristos UV_GETADDRINFO, 480e552da7Schristos UV_GETNAMEINFO, 490e552da7Schristos UV_REQ_TYPE_MAX, 500e552da7Schristos } uv_req_type; 510e552da7Schristos 520e552da7Schristos 530e552da7SchristosAPI 540e552da7Schristos--- 550e552da7Schristos 56*5f2f4271Schristos.. c:macro:: UV_REQ_TYPE_MAP(iter_macro) 570e552da7Schristos 580e552da7Schristos Macro that expands to a series of invocations of `iter_macro` for 590e552da7Schristos each of the request types. `iter_macro` is invoked with two 600e552da7Schristos arguments: the name of the `uv_req_type` element without the `UV_` 610e552da7Schristos prefix, and the name of the corresponding structure type without the 620e552da7Schristos `uv_` prefix and `_t` suffix. 630e552da7Schristos 640e552da7Schristos.. c:function:: int uv_cancel(uv_req_t* req) 650e552da7Schristos 660e552da7Schristos Cancel a pending request. Fails if the request is executing or has finished 670e552da7Schristos executing. 680e552da7Schristos 690e552da7Schristos Returns 0 on success, or an error code < 0 on failure. 700e552da7Schristos 710e552da7Schristos Only cancellation of :c:type:`uv_fs_t`, :c:type:`uv_getaddrinfo_t`, 720e552da7Schristos :c:type:`uv_getnameinfo_t`, :c:type:`uv_random_t` and :c:type:`uv_work_t` 730e552da7Schristos requests is currently supported. 740e552da7Schristos 750e552da7Schristos Cancelled requests have their callbacks invoked some time in the future. 760e552da7Schristos It's **not** safe to free the memory associated with the request until the 770e552da7Schristos callback is called. 780e552da7Schristos 790e552da7Schristos Here is how cancellation is reported to the callback: 800e552da7Schristos 810e552da7Schristos * A :c:type:`uv_fs_t` request has its req->result field set to `UV_ECANCELED`. 820e552da7Schristos 830e552da7Schristos * A :c:type:`uv_work_t`, :c:type:`uv_getaddrinfo_t`, 840e552da7Schristos :c:type:`uv_getnameinfo_t` or :c:type:`uv_random_t` request has its 850e552da7Schristos callback invoked with status == `UV_ECANCELED`. 860e552da7Schristos 870e552da7Schristos.. c:function:: size_t uv_req_size(uv_req_type type) 880e552da7Schristos 890e552da7Schristos Returns the size of the given request type. Useful for FFI binding writers 900e552da7Schristos who don't want to know the structure layout. 910e552da7Schristos 920e552da7Schristos.. c:function:: void* uv_req_get_data(const uv_req_t* req) 930e552da7Schristos 940e552da7Schristos Returns `req->data`. 950e552da7Schristos 960e552da7Schristos .. versionadded:: 1.19.0 970e552da7Schristos 980e552da7Schristos.. c:function:: void* uv_req_set_data(uv_req_t* req, void* data) 990e552da7Schristos 1000e552da7Schristos Sets `req->data` to `data`. 1010e552da7Schristos 1020e552da7Schristos .. versionadded:: 1.19.0 1030e552da7Schristos 1040e552da7Schristos.. c:function:: uv_req_type uv_req_get_type(const uv_req_t* req) 1050e552da7Schristos 1060e552da7Schristos Returns `req->type`. 1070e552da7Schristos 1080e552da7Schristos .. versionadded:: 1.19.0 1090e552da7Schristos 1100e552da7Schristos.. c:function:: const char* uv_req_type_name(uv_req_type type) 1110e552da7Schristos 1120e552da7Schristos Returns the name for the equivalent struct for a given request type, 1130e552da7Schristos e.g. `"connect"` (as in :c:type:`uv_connect_t`) for `UV_CONNECT`. 1140e552da7Schristos 1150e552da7Schristos If no such request type exists, this returns `NULL`. 1160e552da7Schristos 1170e552da7Schristos .. versionadded:: 1.19.0 118