blob: bc2312b528607143b7101945b63141034f80ac05 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
/*
* Created by yuuta on 7/19/22.
*/
#ifndef LIBAC_SERIALIZER_H
#define LIBAC_SERIALIZER_H
#include <json_object.h>
/* An internal error code indicating that more data is required.
* Should not conflict with other error codes. */
#define AC_E_SERIALIZER_CONTINUE -1
/**
* Deserialize an event or a response into ac_obj_t.
* @param string The partial or complete response.
* @param len The length to the string, excluding tailing NULL.
* @param out The final object. Not NULL if the return value is AC_E_OK.
* @return AC_E_OK or an error code. When failed, the *out is untouched.
* MT-Safe config
*/
int deserialize(const char *string, unsigned int len, ac_obj_t **out);
/**
* Force a deserializer reset.
* @return AC_E_OK or an error code.
* MT-Safe
*/
int serializer_finalize(void);
/**
* Serialize a request to a JSON object.
* @param req The request. Must be a valid ac_request.
* @param out The output json_object. Will not be NULL if the return value is AC_E_OK.
* @return AC_E_OK or an error code. When failed, the *out is untouched.
* MT-Safe
*/
int serialize_request(const ac_request_t *req, json_object **out);
#endif /* LIBAC_SERIALIZER_H */
|