From f0cf75a487aff2ecaeda290b51d77c4e8cccb061 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Tue, 31 Dec 2024 14:52:49 -0800 Subject: docs: convert nng_stream_get family --- docs/ref/api/stream.md | 28 ++++++++++++++++++++++++++++ docs/ref/xref.md | 8 ++++++++ 2 files changed, 36 insertions(+) (limited to 'docs/ref') diff --git a/docs/ref/api/stream.md b/docs/ref/api/stream.md index 9609ef7b..37275c93 100644 --- a/docs/ref/api/stream.md +++ b/docs/ref/api/stream.md @@ -76,4 +76,32 @@ stream itself. > or be aborted, these functions are unsafe to call from functions that may not block, such as the > completion function registered with an [`nng_aio`] when it is created. +## Getting Stream Options + +```c +int nng_stream_get_bool(nng_stream *s, const char *opt, bool *valp); +int nng_stream_get_int(nng_stream *s, const char *opt, int *valp); +int nng_stream_get_ms(nng_stream *s, const char *opt, nng_duration *valp); +int nng_stream_get_size(nng_stream *s, const char *opt, size_t *valp); +int nng_stream_get_addr(nng_stream *s, const char *opt, nng_sockaddr *valp); +int nng_stream_get_string(nng_stream *s, const char *opt, char **valp); +int nng_stream_get_uint64(nng_stream *s, const char *opt, uint64_t *valp); +``` + +{{hi:`nng_stream_get_bool`}} +{{hi:`nng_stream_get_int`}} +{{hi:`nng_stream_get_ms`}} +{{hi:`nng_stream_get_size`}} +{{hi:`nng_stream_get_addr`}} +{{hi:`nng_stream_get_string`}} +{{hi:`nng_stream_get_uint64`}} +These functions are used to obtain value of an option named _opt_ from the stream _s_, and store it in the location +referenced by _valp_. + +These functions access an option as a specific type. The transport layer will have details about which options +are available, and which type they may be accessed using. + +In the case of `nng_stream_get_string`, the string is created as if by [`nng_strdup`], and must be freed by +the caller using [`nng_strfree`] when no longer needed. + {{#include ../xref.md}} diff --git a/docs/ref/xref.md b/docs/ref/xref.md index b790dcbd..355ebe37 100644 --- a/docs/ref/xref.md +++ b/docs/ref/xref.md @@ -109,6 +109,14 @@ [`nng_stream_close`]: /api/stream.md#closing-a-stream [`nng_stream_stop`]: /api/stream.md#closing-a-stream [`nng_stream_free`]: /api/stream.md#closing-a-stream +[`nng_stream_get`]: /api/stream.md#getting-stream-options +[`nng_stream_get_bool`]: /api/stream.md#getting-stream-options +[`nng_stream_get_int`]: /api/stream.md#getting-stream-options +[`nng_stream_get_ms`]: /api/stream.md#getting-stream-options +[`nng_stream_get_size`]: /api/stream.md#getting-stream-options +[`nng_stream_get_addr`]: /api/stream.md#getting-stream-options +[`nng_stream_get_string`]: /api/stream.md#getting-stream-options +[`nng_stream_get_uint64`]: /api/stream.md#getting-stream-options [`nng_init`]: /api/init.md#initialization [`nng_fini`]: /api/init.md#finalization [`nng_sub0_ctx_subscribe`]: /TODO.md -- cgit v1.2.3-70-g09d2