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
/* Generated with cbindgen:0.29.0 */
/**
* Loads a snippet by name and returns its JSON representation.
*
* # Arguments
* - `name`: A null-terminated C string representing the name of the snippet.
*
* # Returns
* A newly allocated C string (`*mut c_char`) containing the snippet's JSON representation.
* - On success: JSON-encoded `Snippet` as a C string (must be freed with `free_string_ffi`).
* - On failure: JSON-encoded error object (must also be freed).
*
* # Safety
* - `name` must be a valid, null-terminated UTF-8 string.
* - Caller is responsible for freeing the returned string using `free_string_ffi`.
*/
char *;
/**
* Saves a single snippet from its JSON representation.
*
* # Arguments
* - `snippet_json`: A null-terminated C string containing a JSON-encoded snippet.
*
* # Returns
* - `true` if the snippet was saved successfully.
* - `false` if the input was invalid or saving failed.
*
* # Safety
* - `snippet_json` must be a valid, null-terminated UTF-8 string.
*/
bool ;
/**
* Deletes a snippet from the repo
*
* # Arguments
* - `name`: A Null terminated C String of the snippets' name.
*
* # Returns
* - `true` if the snippet was deleted successfully.
* - `false` if an error occurred.
*
* # Safety
* - `name` needs to be a valid, null-terminated, UTF-8 string.
*/
bool ;
/**
* Loads all snippets from the repository and returns them as a JSON array.
*
* # Returns
* A newly allocated C string (`*mut c_char`) containing the JSON array of all snippets.
* - On success: JSON array of snippets (must be freed with `free_string_ffi`).
* - On failure: JSON-encoded error object (must also be freed).
*
* # Safety
* - Caller is responsible for freeing the returned string using `free_string_ffi`.
*/
char *;
/**
* Saves a list of snippets from a JSON array.
*
* # Arguments
* - `snippets_json`: A null-terminated C string containing a JSON array of snippets.
*
* # Returns
* - `true` if all snippets were saved successfully.
* - `false` if deserialization or saving failed.
*
* # Safety
* - `snippets_json` must be a valid, null-terminated UTF-8 string.
*/
bool ;
/**
* Executes a generic Git command inside the `.nibb` directory and returns the output as JSON.
*
* # Arguments
* - `args`: A pointer to a null-terminated C string containing the Git arguments as a whitespace-separated string, e.g. `"status -s"`.
*
* # Returns
* - A pointer to a null-terminated C string containing a JSON object:
* ```json
* {
* "stdout": "<Git stdout output>",
* "stderr": "<Git stderr output>"
* }
* ```
* - In case of error, `stderr` contains an error message and `stdout` is empty.
*
* # Safety
* - The input C string must be valid and null-terminated.
* - The returned string must be freed by the caller using the appropriate function (e.g., `free_string_ffi`).
*
* # Example (from Lua)
* ```lua
* local output_json = ffi.C.nibb_git_generic_ffi("status -s")
* local output = vim.fn.json_decode(ffi.string(output_json))
* print(output.stdout)
* print(output.stderr)
* ```
*/
const char *;
/**
* Frees a string previously allocated and returned by an FFI function.
*
* # Arguments
* - `s`: A pointer returned by an FFI function like `load_snippet_ffi` or `load_all_ffi`.
*
* # Safety
* - `s` must be a pointer obtained from one of the FFI functions using `CString::into_raw`.
* - Passing a null pointer is safe and does nothing.
* - After calling this function, `s` must not be used again.
*/
void ;