aboutsummaryrefslogtreecommitdiff
path: root/client/libacron/include
diff options
context:
space:
mode:
authorTrumeet <yuuta@yuuta.moe>2022-07-20 20:37:37 -0700
committerTrumeet <yuuta@yuuta.moe>2022-07-20 20:37:37 -0700
commit41ac44c30b9d165dd90255eec5b817fc21b8f7ff (patch)
treecf4fb9a61eef24a96365f54409f47e373ff2e3da /client/libacron/include
parente2452adee6ba683cbfe093301650503a936a1a94 (diff)
downloadacron-41ac44c30b9d165dd90255eec5b817fc21b8f7ff.tar
acron-41ac44c30b9d165dd90255eec5b817fc21b8f7ff.tar.gz
acron-41ac44c30b9d165dd90255eec5b817fc21b8f7ff.tar.bz2
acron-41ac44c30b9d165dd90255eec5b817fc21b8f7ff.zip
docs(libacron): add library docs
Signed-off-by: Trumeet <yuuta@yuuta.moe>
Diffstat (limited to 'client/libacron/include')
-rw-r--r--client/libacron/include/ids.h5
-rw-r--r--client/libacron/include/libac.h4
-rw-r--r--client/libacron/include/net.h19
-rw-r--r--client/libacron/include/requests.h8
4 files changed, 34 insertions, 2 deletions
diff --git a/client/libacron/include/ids.h b/client/libacron/include/ids.h
index 86fde47..80e7448 100644
--- a/client/libacron/include/ids.h
+++ b/client/libacron/include/ids.h
@@ -21,6 +21,11 @@ typedef struct ac_obj {
uint8_t type;
} ac_obj_t;
+/**
+ * Free the object.
+ * @param obj Object to free. Must be a valid object.
+ * @return AC_E_OK or an error code. When succeeds, obj is freed and no longer valid.
+ */
int ac_object_free(ac_obj_t *obj);
#endif /* LIBAC_IDS_H */
diff --git a/client/libacron/include/libac.h b/client/libacron/include/libac.h
index 80734dc..542adcb 100644
--- a/client/libacron/include/libac.h
+++ b/client/libacron/include/libac.h
@@ -21,13 +21,13 @@ typedef struct libac_config {
/**
* Initialize libac for the calling thread.
- * @return 0 on success.
+ * @return AC_E_OK on success.
*/
int ac_init(const libac_config_t *config);
/**
* Destroy libac configuration for the calling thread.
- * @return 0 on success.
+ * @return AC_E_OK on success.
*/
int ac_free(void);
diff --git a/client/libacron/include/net.h b/client/libacron/include/net.h
index 5b10470..8fb33f8 100644
--- a/client/libacron/include/net.h
+++ b/client/libacron/include/net.h
@@ -20,10 +20,29 @@ typedef struct ac_connection_parameters {
char *url;
} ac_connection_parameters_t;
+/**
+ * Connect to the server.
+ * @param parameters Connection parameters. Untouched.
+ * @param out Output connection reference if succeeds. Not-NULL.
+ * @return AC_E_OK or an error code. When failed, *out will be untouched.
+ * MT-Safe
+ */
int ac_connect(ac_connection_parameters_t parameters, void **out);
+/**
+ * Disconnect the connection.
+ * @param connection A non-NULL and connected connection passed as-is from ac_connect.
+ * @return AC_E_OK or an error code. When failed, connection is undefined. When succeeds, connection is freed and invalid.
+ * MT-Unsafe
+ */
int ac_disconnect(void *connection);
+/**
+ * Blocks the current thread until a new response or event arrives.
+ * @param connection A non-NULL and connected connection passed as-is from ac_connect.
+ * @param response Output response of either an event or a response. May be NULL even if it succeeds.
+ * @return AC_E_OK or an error code. When failed, *response is NULL.
+ */
int ac_receive(void *connection, ac_obj_t **response);
#endif /* LIBAC_NET_H */
diff --git a/client/libacron/include/requests.h b/client/libacron/include/requests.h
index 40742e0..590bb2e 100644
--- a/client/libacron/include/requests.h
+++ b/client/libacron/include/requests.h
@@ -66,6 +66,14 @@ typedef struct ac_request_set_config {
ac_config_t config;
} ac_request_set_config_t;
+/**
+ * Send a request to the connection. If this function succeeds, ac_receive() will return a response
+ * with the same ID later.
+ * @param connection Must be a non-NULL and connected connection, or it will return AC_E_INVALID_REQUEST.
+ * @param request A valid ac_request_t. It will left untouched.
+ * @return AC_E_OK or an error code.
+ * MT-Unsafe: Must be called on the same thread calling ac_receive().
+ */
int ac_request(void *connection, const ac_request_t *request);
#endif /* LIBAC_REQUESTS_H */