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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
use crateValue;
/// Submodules providing specialized functions for different types of `Value`.
///
/// Each module handles operations specific to the type, for example:
/// - `_8b_functions` : Functions for 8-bit values
/// - `_16b_functions`: Functions for 16-bit values
/// - `_32b_functions`: Functions for 32-bit values
/// - `_64b_functions`: Functions for 64-bit values
/// - `_bool_functions`: Functions for boolean values
/// - `_string_functions`: Functions for string values
/// - `_array_functions`: Functions for array values
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
/// Frees a `Value` previously allocated on the heap.
///
/// # Parameters
/// - `val`: Pointer to a `Value`.
///
/// # Safety
/// - `val` must be a pointer previously returned from a creation function.
/// - After calling this function, the pointer must not be used again.
pub extern "C"
/// Decodes a buffer of bytes into a heap-allocated `Value`.
///
/// # Safety
/// - The caller must ensure that `buff` points to a valid memory region of at least `len` bytes.
/// - The returned pointer transfers ownership of the `Value` to the caller.
/// The caller is responsible for freeing it with `Box::from_raw` or a dedicated free function.
///
/// # Parameters
/// - `buff`: Pointer to a contiguous buffer of `u8` containing the encoded value.
/// - `len`: Length of the buffer in bytes.
///
/// # Returns
/// - A raw pointer to a heap-allocated `Value` on success.
/// - Returns `null` if `buff` is null, `len` is zero, or decoding fails.
///
/// # Notes
/// - This function creates a temporary Rust `Vec<u8>` from the raw buffer to pass to `Value::decode`.
/// - Ownership of the returned `Value` is fully transferred; Rust will not automatically free it.
/// - The caller must ensure proper deallocation to avoid memory leaks.
pub extern "C"
/// Returns the type of the `Value`.
///
/// # Parameters
/// - `val`: Pointer to a `Value`.
///
/// # Returns
/// - A `u8` representing the type.
/// - Returns `0` if `val` is null.
///
/// # Safety
/// - `val` must be a valid pointer or null.
pub extern "C"
/// Returns the length of the `Value` in bytes (or its logical length).
///
/// # Parameters
/// - `val`: Pointer to a `Value`.
///
/// # Returns
/// - Length as `u8`.
/// - Returns `0` if `val` is null.
///
/// # Safety
/// - `val` must be a valid pointer or null.
pub extern "C"
/// Returns a raw pointer to the underlying bytes of the `Value`.
///
/// # Parameters
/// - `val`: Pointer to a `Value`.
///
/// # Returns
/// - Pointer to the first byte of the value, or null if `val` is null.
///
/// # Safety
/// - The returned pointer is valid as long as the `Value` is alive.
/// - Modifying the memory through this pointer may cause undefined behavior.
pub extern "C"
/// Returns the length of the raw byte buffer of the `Value`.
///
/// # Parameters
/// - `val`: Pointer to a `Value`.
///
/// # Returns
/// - Number of bytes in the `Value`, or `0` if `val` is null.
///
/// # Safety
/// - `val` must be a valid pointer or null.
pub extern "C"