2016-05-27 22:50:46 -05:00
|
|
|
# uv_link_t
|
|
|
|
|
2016-05-27 23:26:25 -05:00
|
|
|
## General notes
|
|
|
|
|
|
|
|
All methods with `int` return value return `0` on success or error code, unless
|
|
|
|
specified otherwise.
|
|
|
|
|
2016-05-28 11:36:28 -05:00
|
|
|
Fields not listed here a considered private and should not be modified/relied
|
|
|
|
upon in user applications.
|
|
|
|
|
2016-05-27 22:55:12 -05:00
|
|
|
## uv_link_t
|
2016-05-27 22:50:46 -05:00
|
|
|
|
|
|
|
The base unit of all APIs. Pointer to this structure is what needs to be passed
|
|
|
|
to the most of the methods.
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
*NOTE: please don't call methods from [`uv_link_methods_t`][] directly. There
|
|
|
|
are plenty of API methods that wrap this calls in a simpler and portable
|
|
|
|
manner.*
|
2016-05-28 11:08:03 -05:00
|
|
|
|
2016-05-27 22:55:12 -05:00
|
|
|
### int uv_link_init(...)
|
2016-05-27 23:26:25 -05:00
|
|
|
|
|
|
|
* `uv_link_t* link` - user allocated `uv_link_t` instance
|
|
|
|
* `uv_link_methods_t const* methods` - user defined link methods, see
|
2016-05-28 11:32:12 -05:00
|
|
|
[`uv_link_methods_t`][] below
|
2016-05-27 23:26:25 -05:00
|
|
|
|
|
|
|
Initialize `link` structure with provided `methods`.
|
|
|
|
|
|
|
|
This is a first method to be called on `uv_link_t` instance before it could be
|
|
|
|
used in any other APIs.
|
|
|
|
|
2016-05-27 22:55:12 -05:00
|
|
|
### void uv_link_close(...)
|
2016-05-27 23:26:25 -05:00
|
|
|
|
|
|
|
* `uv_link_t* link` - `uv_link_t` instance to close
|
|
|
|
* `uv_link_close_cb cb` - callback to be invoked upon close
|
|
|
|
|
|
|
|
Close `uv_link_t` instance and all other `uv_link_t`s chained into it (see
|
2016-05-28 11:32:12 -05:00
|
|
|
[`uv_link_chain()`][]), invoke `void (*cb)(uv_link_t*)` once done (may happen
|
2016-05-27 23:26:25 -05:00
|
|
|
synchronously or on a next libuv tick, depending on particular `uv_link_t`
|
|
|
|
implementation).
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
Invokes `close` from link's [`uv_link_methods_t`][].
|
2016-05-27 23:26:25 -05:00
|
|
|
|
|
|
|
*NOTE: this method must be called on a leaf link that has no chaining child*
|
|
|
|
|
2016-05-27 22:55:12 -05:00
|
|
|
### int uv_link_chain(...)
|
2016-05-27 23:26:25 -05:00
|
|
|
|
|
|
|
* `uv_link_t* from`
|
|
|
|
* `uv_link_t* to`
|
|
|
|
|
|
|
|
"Chain" two `uv_link_t` instances together, set `from.child = to` and
|
|
|
|
`to.parent = from`. After this call, all data emitted by `from` link via
|
2016-05-28 11:32:12 -05:00
|
|
|
[`uv_link_propagate_alloc_cb()`][] and [`uv_link_propagate_read_cb()`][] will be
|
|
|
|
passed to `to` link's [`uv_link_methods_t`][]'s
|
|
|
|
[`uv_link_methods_t.alloc_cb_override`][] and
|
|
|
|
[`uv_link_methods_t.read_cb_override`][].
|
2016-05-27 23:26:25 -05:00
|
|
|
|
|
|
|
Closing `to` with `uv_link_close` will also close `from`, unless they will be
|
2016-05-28 11:32:12 -05:00
|
|
|
later unchained with [`uv_link_unchain()`][].
|
2016-05-27 23:26:25 -05:00
|
|
|
|
|
|
|
*NOTE: Links can have at most one parent and one child.*
|
|
|
|
|
2016-05-27 22:55:12 -05:00
|
|
|
### int uv_link_unchain(...)
|
2016-05-27 23:26:25 -05:00
|
|
|
|
|
|
|
* `uv_link_t* from`
|
|
|
|
* `uv_link_t* to`
|
|
|
|
|
|
|
|
Unlink chains, restoring `from.read_cb` and `from.alloc_cb` to their previous
|
|
|
|
values (that they had before `uv_link_unchain()` call).
|
|
|
|
|
2016-05-27 22:55:12 -05:00
|
|
|
### int uv_link_read_start(...)
|
2016-05-27 23:26:25 -05:00
|
|
|
|
|
|
|
* `uv_link_t* link`
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
Invoke `read_start` from the link's [`uv_link_methods_t`][].
|
|
|
|
[`uv_link_t.alloc_cb`][]/[`uv_link_t.read_cb`][] may be called after successful
|
2016-05-28 11:19:07 -05:00
|
|
|
`uv_link_read_start`.
|
2016-05-27 23:26:25 -05:00
|
|
|
|
2016-05-27 22:55:12 -05:00
|
|
|
### int uv_link_read_stop(...)
|
2016-05-27 23:26:25 -05:00
|
|
|
|
|
|
|
* `uv_link_t* link`
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
Invoke `read_stop` from the link's [`uv_link_methods_t`][].
|
|
|
|
[`uv_link_t.alloc_cb`][]/[`uv_link_t.read_cb`][] won't be called after
|
2016-05-28 11:19:07 -05:00
|
|
|
`uv_link_read_stop`.
|
2016-05-27 23:26:25 -05:00
|
|
|
|
2016-05-27 22:55:12 -05:00
|
|
|
### int uv_link_write(...)
|
2016-05-27 23:26:25 -05:00
|
|
|
|
|
|
|
* `uv_link_t* link`
|
|
|
|
* `const uv_buf_t bufs[]` - buffers to write
|
|
|
|
* `unsigned int nbufs` - number of buffers to write
|
|
|
|
* `uv_stream_t* send_handle` - handle to send through IPC (if supported by
|
2016-05-28 11:32:12 -05:00
|
|
|
underlying [`uv_link_source_t`][])
|
2016-05-27 23:26:25 -05:00
|
|
|
* `uv_link_write_cb cb` - callback to be invoked
|
|
|
|
* `void* arg` - user data to be passed to callback
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
Invoke `write` from the link's [`uv_link_methods_t`][]. Acts similarly to
|
|
|
|
`uv_write()`. `cb(uv_link_t* link, int status, void* arg)` is invoked on
|
|
|
|
completion.
|
2016-05-27 23:26:25 -05:00
|
|
|
|
2016-05-27 22:55:12 -05:00
|
|
|
### int uv_link_try_write(...)
|
2016-05-27 23:26:25 -05:00
|
|
|
|
|
|
|
* `uv_link_t* link`
|
|
|
|
* `const uv_buf_t bufs[]` - buffers to write
|
|
|
|
* `unsigned int nbufs` - number of buffers to write
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
Invoke `try_write` from the link's [`uv_link_methods_t`][]. Acts similarly to
|
2016-05-27 23:26:25 -05:00
|
|
|
`uv_try_write()`.
|
|
|
|
|
|
|
|
Returns number of bytes written, or negative error code.
|
|
|
|
|
2016-05-27 22:55:12 -05:00
|
|
|
### int uv_link_shutdown(...)
|
|
|
|
|
2016-05-27 23:26:25 -05:00
|
|
|
* `uv_link_t* link`
|
|
|
|
* `uv_link_shutdown_cb cb` - callback to be invoked
|
|
|
|
* `void* arg` - user data to be passed to callback
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
Invoke `shutdown` from the link's [`uv_link_methods_t`][]. Acts similarly to
|
2016-05-27 23:26:25 -05:00
|
|
|
`uv_shutdown()`. `cb(uv_link_t* link, int status, void* arg)` is invoked on
|
|
|
|
completion.
|
|
|
|
|
2016-06-04 18:25:26 -05:00
|
|
|
### int uv_link_errno(...)
|
|
|
|
|
|
|
|
* `uv_link_t** link`
|
2017-04-18 15:58:58 -05:00
|
|
|
* `int err` - error code, previously either returned by the one of
|
2016-06-04 18:25:26 -05:00
|
|
|
`uv_link...` methods or passed as a negative `nread` to `link->read_cb`
|
|
|
|
|
|
|
|
Unprefix internal error code and set the `link` pointer to the link that
|
|
|
|
have emitted that error.
|
|
|
|
|
2016-06-04 13:37:26 -05:00
|
|
|
### const char* uv_link_strerror(...)
|
|
|
|
|
|
|
|
* `uv_link_t* link`
|
|
|
|
* `int err` - error code, previously either returned the one of the
|
|
|
|
`uv_link...` methods or passed as a negative `nread` to `link->read_cb`
|
|
|
|
|
|
|
|
Invoke `strerror` from the link's [`uv_link_methods_t`][]. Acts similarly to
|
|
|
|
`uv_strerror()`. Returns a description of error code that has just been given
|
|
|
|
back to the user.
|
|
|
|
|
2016-05-27 23:26:25 -05:00
|
|
|
### void uv_link_propagate_alloc_cb(...)
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
Should be used only by [`uv_link_methods_t`][] implementation.
|
2016-05-27 23:26:25 -05:00
|
|
|
|
|
|
|
* `uv_link_t* link`
|
|
|
|
* `size_t suggested_size`
|
|
|
|
* `uv_buf_t* buf`
|
|
|
|
|
|
|
|
Arguments have the same meaning as in `uv_alloc_cb`. When calling this function
|
|
|
|
`link->alloc_cb` will be invoked with either `link` or `link->child` (if latter
|
|
|
|
is not `NULL`).
|
|
|
|
|
|
|
|
This should be used to emit data from `uv_link_t`. Semantics are the same as of
|
|
|
|
`uv_alloc_cb`.
|
|
|
|
|
|
|
|
### void uv_link_propagate_read_cb(...)
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
Should be used only by [`uv_link_methods_t`][] implementation.
|
2016-05-27 23:26:25 -05:00
|
|
|
|
|
|
|
* `uv_link_t* link`
|
|
|
|
* `ssize_t nread`
|
|
|
|
* `const uv_buf_t* buf`
|
|
|
|
|
|
|
|
Arguments have the same meaning as in `uv_read_cb`. When calling this function
|
|
|
|
`link->read_cb` will be invoked with either `link` or `link->child` (if latter
|
|
|
|
is not `NULL`).
|
|
|
|
|
2016-05-28 11:08:03 -05:00
|
|
|
Should be used to emit data from `uv_link_t`. Semantics are the same as of
|
2016-05-27 23:26:25 -05:00
|
|
|
`uv_read_cb`.
|
|
|
|
|
|
|
|
### int uv_link_propagate_write(...)
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
Should be used only by [`uv_link_methods_t`][] implementation.
|
2016-05-27 23:26:25 -05:00
|
|
|
|
2016-05-28 11:08:03 -05:00
|
|
|
* `uv_link_t* link`
|
|
|
|
* `uv_link_t* source` - source link to be passed to `cb` as a first argument
|
|
|
|
* `const uv_buf_t bufs[]` - buffers to write
|
|
|
|
* `unsigned int nbufs` - number of buffers to write
|
|
|
|
* `uv_stream_t* send_handle` - handle to send through IPC (if supported by
|
2016-05-28 11:32:12 -05:00
|
|
|
underlying [`uv_link_source_t`][])
|
2016-05-28 11:08:03 -05:00
|
|
|
* `uv_link_write_cb cb` - callback to be invoked
|
|
|
|
* `void* arg` - user data to be passed to callback
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
Invoke `write` from the`link`'s [`uv_link_methods_t`][]. Could be used to
|
2016-05-28 11:08:03 -05:00
|
|
|
pass through the data in a following way:
|
|
|
|
|
|
|
|
```c
|
|
|
|
uv_link_propagate_write(link->parent, source, ...);
|
|
|
|
```
|
|
|
|
|
|
|
|
*NOTE: `source` and `cb` may be passed through multiple links to avoid storing
|
|
|
|
extra data in auxilliary structures.*
|
|
|
|
|
2016-05-27 23:26:25 -05:00
|
|
|
### int uv_link_propagate_shutdown(...)
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
Should be used only by [`uv_link_methods_t`][] implementation.
|
2016-05-27 23:26:25 -05:00
|
|
|
|
2016-05-28 11:08:03 -05:00
|
|
|
* `uv_link_t* link`
|
|
|
|
* `uv_link_t* source` - source link to be passed to `cb` as a first argument
|
|
|
|
* `uv_link_shutdown_cb cb` - callback to be invoked
|
|
|
|
* `void* arg` - user data to be passed to callback
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
Invoke `shutdown` from the`link`'s [`uv_link_methods_t`][]. Could be used to
|
2016-05-28 11:08:03 -05:00
|
|
|
pass through shutdown request in a following way:
|
|
|
|
|
|
|
|
```c
|
|
|
|
uv_link_propagate_shutdown(link->parent, source, ...);
|
|
|
|
```
|
|
|
|
|
|
|
|
*NOTE: `source` and `cb` may be passed through multiple links to avoid storing
|
|
|
|
extra data in auxilliary structures.*
|
|
|
|
|
2016-05-27 23:26:25 -05:00
|
|
|
### void uv_link_propagate_close(...)
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
Should be used only by [`uv_link_methods_t`][] implementation.
|
2016-05-27 23:26:25 -05:00
|
|
|
|
2016-05-28 11:08:03 -05:00
|
|
|
* `uv_link_t* link`
|
|
|
|
* `uv_link_t* source` - source link to be passed to `cb` as a first argument
|
|
|
|
* `uv_link_close_cb cb` - callback to be invoked
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
Invoke `close` from the`link`'s [`uv_link_methods_t`][]. Could be used to
|
2016-05-28 11:08:03 -05:00
|
|
|
close auxiliary links that are not in a current chain.
|
|
|
|
|
|
|
|
`source` MUST be a leaf link of chain that is currently being closed.
|
|
|
|
|
2016-05-27 23:26:25 -05:00
|
|
|
### .data
|
|
|
|
|
2016-05-28 11:08:03 -05:00
|
|
|
```c
|
|
|
|
void* data;
|
|
|
|
```
|
|
|
|
|
2016-05-27 23:27:31 -05:00
|
|
|
Property of `void*` type, any value may be stored here. Not used internally.
|
2016-05-27 23:26:25 -05:00
|
|
|
|
|
|
|
### .alloc_cb
|
2016-05-28 11:08:03 -05:00
|
|
|
|
|
|
|
```c
|
|
|
|
typedef void (*uv_link_alloc_cb)(uv_link_t* link,
|
|
|
|
size_t suggested_size,
|
|
|
|
uv_buf_t* buf);
|
|
|
|
```
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
Invoked by [`uv_link_propagate_alloc_cb()`][] to emit data on `link`.
|
2016-05-28 11:08:03 -05:00
|
|
|
Semantics are the same as in `uv_alloc_cb`.
|
|
|
|
|
|
|
|
By default contains a function that `malloc`s `suggested_size`.
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
Overridden on [`uv_link_chain()`][] call by the value of
|
|
|
|
[`uv_link_methods_t.alloc_cb_override`][] from the child link's
|
|
|
|
[`uv_link_methods_t`][].
|
2016-05-28 11:08:03 -05:00
|
|
|
|
2016-05-27 23:26:25 -05:00
|
|
|
### .read_cb
|
2016-05-28 11:08:03 -05:00
|
|
|
|
|
|
|
```c
|
|
|
|
typedef void (*uv_link_read_cb)(uv_link_t* link,
|
|
|
|
ssize_t nread,
|
|
|
|
const uv_buf_t* buf);
|
|
|
|
```
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
Invoked by [`uv_link_propagate_read_cb()`][] to emit data on `link`.
|
2016-05-28 11:08:03 -05:00
|
|
|
Semantics are the same as in `uv_read_cb`.
|
|
|
|
|
|
|
|
By default just `free`s the `buf->base`, if `buf` is not `NULL`.
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
Overridden on [`uv_link_chain()`][] call by the value of
|
|
|
|
[`uv_link_methods_t.read_cb_override`][] from the child link's
|
|
|
|
[`uv_link_methods_t`][].
|
2016-05-28 11:08:03 -05:00
|
|
|
|
2016-05-27 23:26:25 -05:00
|
|
|
### .parent
|
2016-05-28 11:08:03 -05:00
|
|
|
|
|
|
|
```c
|
|
|
|
uv_link_t* parent;
|
|
|
|
```
|
|
|
|
|
|
|
|
Pointer to the parent link in a chain. Default value: `NULL`.
|
|
|
|
|
2016-05-27 23:26:25 -05:00
|
|
|
### .child
|
|
|
|
|
2016-05-28 11:08:03 -05:00
|
|
|
```c
|
|
|
|
uv_link_t* child;
|
|
|
|
```
|
|
|
|
|
|
|
|
Pointer to the child link in a chain. Default value: `NULL`.
|
|
|
|
|
2016-05-27 23:26:25 -05:00
|
|
|
## uv_link_methods_t
|
|
|
|
|
2016-05-28 11:08:03 -05:00
|
|
|
Methods table, can be shared by multiple links. In the most of the cases should
|
|
|
|
be a pointer to a static structure, since it is immutable and contains only
|
|
|
|
pointers to the functions.
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
Must be provided to [`uv_link_init()`][].
|
2016-05-28 11:08:03 -05:00
|
|
|
|
2016-05-31 19:34:14 -05:00
|
|
|
These functions could be used as a default implementations of
|
|
|
|
`uv_link_methods_t` callbacks:
|
|
|
|
|
|
|
|
```c
|
|
|
|
int uv_link_default_read_start(uv_link_t* link);
|
|
|
|
int uv_link_default_read_stop(uv_link_t* link);
|
|
|
|
int uv_link_default_write(uv_link_t* link,
|
|
|
|
uv_link_t* source,
|
|
|
|
const uv_buf_t bufs[],
|
|
|
|
unsigned int nbufs,
|
|
|
|
uv_stream_t* send_handle,
|
|
|
|
uv_link_write_cb cb,
|
|
|
|
void* arg);
|
|
|
|
int uv_link_default_try_write(uv_link_t* link,
|
|
|
|
const uv_buf_t bufs[],
|
|
|
|
unsigned int nbufs);
|
|
|
|
int uv_link_default_shutdown(uv_link_t* link,
|
|
|
|
uv_link_t* source,
|
|
|
|
uv_link_shutdown_cb cb,
|
|
|
|
void* arg);
|
|
|
|
void uv_link_default_close(uv_link_t* link, uv_link_t* source,
|
|
|
|
uv_link_close_cb cb);
|
2016-06-04 13:37:26 -05:00
|
|
|
const char* uv_link_default_strerror(uv_link_t* link, int err);
|
2016-05-31 19:34:14 -05:00
|
|
|
```
|
|
|
|
|
|
|
|
These maybe used for [`uv_methods_talloc_cb_override`][] and
|
|
|
|
[`uv_methods_t.read_cb_override`][].
|
|
|
|
|
|
|
|
```c
|
2016-06-04 09:26:23 -05:00
|
|
|
void uv_link_default_alloc_cb_override(uv_link_t* link,
|
|
|
|
size_t suggested_size,
|
|
|
|
uv_buf_t* buf);
|
|
|
|
void uv_link_default_read_cb_override(uv_link_t* link,
|
|
|
|
ssize_t nread,
|
|
|
|
const uv_buf_t* buf);
|
2016-05-31 19:34:14 -05:00
|
|
|
```
|
|
|
|
|
2016-05-28 11:08:03 -05:00
|
|
|
### .read_start
|
|
|
|
|
|
|
|
```c
|
|
|
|
int (*read_start)(uv_link_t* link);
|
|
|
|
```
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
Invoked by [`uv_link_read_start()`][]. Data may be emitted after this call.
|
2016-05-28 11:08:03 -05:00
|
|
|
|
|
|
|
*NOTE: semantics are the same as of `uv_read_start`.*
|
|
|
|
|
|
|
|
### .read_stop
|
|
|
|
|
|
|
|
```c
|
|
|
|
int (*read_stop)(uv_link_t* link);
|
|
|
|
```
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
Invoked by [`uv_link_read_stop()`][]. Data MUST not be emitted after this call.
|
2016-05-28 11:08:03 -05:00
|
|
|
|
|
|
|
*NOTE: semantics are the same as of `uv_read_stop`.*
|
|
|
|
|
|
|
|
### .write
|
|
|
|
|
|
|
|
```c
|
|
|
|
int (*write)(uv_link_t* link,
|
|
|
|
uv_link_t* source,
|
|
|
|
const uv_buf_t bufs[],
|
|
|
|
unsigned int nbufs,
|
|
|
|
uv_stream_t* send_handle,
|
|
|
|
uv_link_write_cb cb,
|
|
|
|
void* arg);
|
|
|
|
```
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
Invoked by [`uv_link_write()`][] or by [`uv_link_propagate_write()`][].
|
2016-05-28 11:08:03 -05:00
|
|
|
|
|
|
|
At the time of completion of operation `cb(source, ...)` MUST be called, `link`
|
|
|
|
is passed only only for internal operation.
|
|
|
|
|
|
|
|
*NOTE: semantics are the same as of `uv_write2`.*
|
|
|
|
|
|
|
|
### .try_write
|
|
|
|
|
|
|
|
```c
|
|
|
|
int (*try_write)(uv_link_t* link,
|
|
|
|
const uv_buf_t bufs[],
|
|
|
|
unsigned int nbufs);
|
|
|
|
```
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
Invoked by [`uv_link_try_write()`][].
|
2016-05-28 11:08:03 -05:00
|
|
|
|
|
|
|
*NOTE: semantics are the same as of `uv_try_write`.*
|
|
|
|
|
|
|
|
### .shutdown
|
|
|
|
|
|
|
|
```c
|
|
|
|
int (*shutdown)(uv_link_t* link,
|
|
|
|
uv_link_t* source,
|
|
|
|
uv_link_shutdown_cb cb,
|
|
|
|
void* arg);
|
|
|
|
```
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
Invoked by [`uv_link_shutdown()`][] or [`uv_link_propagate_shutdown`][].
|
2016-05-28 11:08:03 -05:00
|
|
|
|
|
|
|
At the time of completion of operation `cb(source, ...)` MUST be called, `link`
|
|
|
|
is passed only only for internal operation.
|
|
|
|
|
|
|
|
*NOTE: semantics are the same as of `uv_shutdown`.*
|
|
|
|
|
|
|
|
### .close
|
|
|
|
|
|
|
|
```c
|
|
|
|
void (*close)(uv_link_t* link, uv_link_t* source, uv_link_close_cb cb);
|
|
|
|
```
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
Invoked by [`uv_link_close()`][] or [`uv_link_propagate_close`][].
|
2016-05-28 11:08:03 -05:00
|
|
|
|
|
|
|
At the time of completion of operation `cb(source, ...)` MUST be called, `link`
|
|
|
|
is passed only only for internal operation.
|
|
|
|
|
|
|
|
*NOTE: semantics are the same as of `uv_close`.*
|
|
|
|
|
2016-06-04 13:37:26 -05:00
|
|
|
### .strerror
|
|
|
|
|
|
|
|
```c
|
|
|
|
const char* (*strerror)(uv_link_t* link, int err);
|
|
|
|
```
|
|
|
|
|
|
|
|
Invoked by [`uv_link_strerror()`][].
|
|
|
|
|
|
|
|
Should return a description string of the `err` that was emitted by the `link`.
|
|
|
|
|
|
|
|
*NOTE: semantics are the same as of `uv_strerror`.*
|
|
|
|
|
2016-05-28 11:08:03 -05:00
|
|
|
### .alloc_cb_override
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
A method used to override that value of [`uv_link_t.alloc_cb`][] by
|
|
|
|
[`uv_link_chain()`][] call.
|
2016-05-28 11:08:03 -05:00
|
|
|
|
|
|
|
*NOTE: this method will always receive a `link` associated with a
|
2016-05-28 11:32:12 -05:00
|
|
|
[`uv_link_methods_t`][] that has this `alloc_cb_override`. This is guaranteed by
|
|
|
|
the API.*
|
2016-05-28 11:08:03 -05:00
|
|
|
|
|
|
|
### .read_cb_override
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
A method used to override that value of [`uv_link_t.read_cb`][] by
|
|
|
|
[`uv_link_chain()`][] call.
|
2016-05-28 11:08:03 -05:00
|
|
|
|
|
|
|
*NOTE: this method will always receive a `link` associated with a
|
2016-05-28 11:32:12 -05:00
|
|
|
[`uv_link_methods_t`][] that has this `read_cb_override`. This is guaranteed by
|
|
|
|
the API.*
|
2016-05-28 11:08:03 -05:00
|
|
|
|
2016-05-27 22:55:12 -05:00
|
|
|
## uv_link_source_t
|
|
|
|
|
2016-05-28 11:19:07 -05:00
|
|
|
A bridge between `libuv`'s `uv_stream_t` and `uv_link_t`. Emits all incoming
|
2016-05-28 11:32:12 -05:00
|
|
|
data with [`uv_link_t.alloc_cb`][] and [`uv_link_t.read_cb`][], propagates all
|
|
|
|
other methods as they are to `libuv`.
|
2016-05-28 11:19:07 -05:00
|
|
|
|
|
|
|
Can be cast to `uv_link_t`:
|
|
|
|
```
|
|
|
|
uv_link_source_t* source = ...;
|
|
|
|
uv_link_t* link = (uv_link_t*) source;
|
|
|
|
```
|
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
*NOTE: `stream.data` is used by `uv_link_source_t` internally.*
|
|
|
|
|
2016-05-28 11:19:07 -05:00
|
|
|
*NOTE: Most of the applications will use this structure as a root link in their
|
|
|
|
chains, since it is capable of sending/reading data from the socket/pipe/etc.*
|
|
|
|
|
|
|
|
*NOTE: All `uv_link_...` methods can be used with `uv_link_source_t`*
|
|
|
|
|
2016-05-27 22:55:12 -05:00
|
|
|
### int uv_link_source_init(...)
|
2016-05-28 11:19:07 -05:00
|
|
|
|
|
|
|
* `uv_link_source_t* source` - structure to initialize
|
|
|
|
* `uv_stream_t* stream` - `uv_stream_t` to use
|
|
|
|
|
|
|
|
Initialize `uv_link_source_t` structure to work with `stream`.
|
|
|
|
|
|
|
|
*NOTE: `uv_link_source_t` will `uv_close` the `stream` on `uv_link_close`,
|
|
|
|
however it does not manage the pointer to the stream, so it MUST be released
|
|
|
|
separately if it was allocated.*
|
2016-05-27 22:55:12 -05:00
|
|
|
|
|
|
|
## uv_link_observer_t
|
|
|
|
|
2016-05-28 11:19:07 -05:00
|
|
|
A helper structure to observe (*not manage*) the reads of the link. When links
|
2016-05-28 11:32:12 -05:00
|
|
|
are chained - [`uv_link_t.read_cb`][]/[`uv_link_t.alloc_cb`][] are overwritten
|
|
|
|
by [`uv_link_chain()`][]. `uv_link_observer_t` provides a consistent way to
|
|
|
|
observe the reads on a link, even if the link will be chained with another link
|
|
|
|
later on. Use [`uv_link_observer_t.observer_read_cb`][] property to set up read
|
|
|
|
callback.
|
2016-05-28 11:19:07 -05:00
|
|
|
|
|
|
|
Can be cast to `uv_link_t`:
|
|
|
|
```
|
|
|
|
uv_link_observer_t* observer = ...;
|
|
|
|
uv_link_t* link = (uv_link_t*) observer;
|
|
|
|
```
|
|
|
|
|
|
|
|
*NOTE: All `uv_link_...` methods can be used with `uv_link_source_t`*
|
|
|
|
|
2016-05-27 22:55:12 -05:00
|
|
|
### int uv_link_observer_init(...)
|
2016-05-28 11:19:07 -05:00
|
|
|
|
|
|
|
* `uv_link_observer_t* observer` - structure to initialize
|
|
|
|
|
|
|
|
Initialize the structure.
|
|
|
|
|
2016-05-27 22:55:12 -05:00
|
|
|
### .observer_read_cb
|
2016-05-28 11:19:07 -05:00
|
|
|
|
|
|
|
```c
|
|
|
|
void (*observer_read_cb)(uv_link_observer_t* observer,
|
|
|
|
ssize_t nread,
|
|
|
|
const uv_buf_t* buf);
|
|
|
|
```
|
|
|
|
|
|
|
|
Invoked by `uv_link_propagate_read_cb`. MUST not manage the data in `buf`.
|
2016-05-28 11:21:27 -05:00
|
|
|
|
2016-05-28 11:32:12 -05:00
|
|
|
[`uv_link_chain()`]: #int-uv_link_chain
|
|
|
|
[`uv_link_close()`]: #void-uv_link_close
|
2016-06-04 13:37:26 -05:00
|
|
|
[`uv_link_strerror()`]: #const-char-uv_link_strerror
|
2016-05-28 11:32:12 -05:00
|
|
|
[`uv_link_init()`]: #int-uv_link_init
|
|
|
|
[`uv_link_methods_t`]: #uv_link_methods_t
|
|
|
|
[`uv_link_observer_t.observer_read_cb`]: #observer_read_cb
|
|
|
|
[`uv_link_propagate_alloc_cb()`]: #void-uv_link_propagate_alloc_cb
|
|
|
|
[`uv_link_propagate_close`]: #void-uv_link_propagate_close
|
|
|
|
[`uv_link_propagate_read_cb()`]: #void-uv_link_propagate_read_cb
|
|
|
|
[`uv_link_propagate_shutdown`]: #int-uv_link_propagate_shutdown
|
|
|
|
[`uv_link_propagate_write()`]: #int-uv_link_propagate_write
|
|
|
|
[`uv_link_read_start()`]: #int-uv_link_read_start
|
|
|
|
[`uv_link_read_stop()`]: #int-uv_link_read_stop
|
|
|
|
[`uv_link_shutdown()`]: #int-uv_link_shutdown
|
|
|
|
[`uv_link_source_t`]: #uv_link_source_t
|
|
|
|
[`uv_link_t.alloc_cb`]: #alloc_cb
|
|
|
|
[`uv_link_t.read_cb`]: #read_cb
|
|
|
|
[`uv_link_try_write()`]: #int-uv_link_try_write
|
|
|
|
[`uv_link_unchain()`]: #int-uv_link_unchain
|
|
|
|
[`uv_link_write()`]: #int-uv_link_write
|
|
|
|
[`uv_link_methods_t.alloc_cb_override`]: #alloc_cb_override
|
|
|
|
[`uv_link_methods_t.read_cb_override`]: #read_cb_override
|