1/*===----------------------------------------------------------------------===*\
2|* *|
3|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
4|* Exceptions. *|
5|* See https://llvm.org/LICENSE.txt for license information. *|
6|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
7|* *|
8|*===----------------------------------------------------------------------===*|
9|* *|
10|* The types for the LLVM CAS plugin API. *|
11|* The API is experimental and subject to change. *|
12|* *|
13\*===----------------------------------------------------------------------===*/
14
15#ifndef LLVM_C_CAS_PLUGINAPI_TYPES_H
16#define LLVM_C_CAS_PLUGINAPI_TYPES_H
17
18#include <stdbool.h>
19#include <stddef.h>
20#include <stdint.h>
21
22#define LLCAS_VERSION_MAJOR 0
23#define LLCAS_VERSION_MINOR 2
24
25typedef struct llcas_cas_options_s *llcas_cas_options_t;
26typedef struct llcas_cas_s *llcas_cas_t;
27typedef struct llcas_cancellable_s *llcas_cancellable_t;
28
29/**
30 * Digest hash bytes.
31 */
32typedef struct {
33 const uint8_t *data;
34 size_t size;
35} llcas_digest_t;
36
37/**
38 * Data buffer for stored CAS objects.
39 */
40typedef struct {
41 const void *data;
42 size_t size;
43} llcas_data_t;
44
45/**
46 * Identifier for a CAS object.
47 */
48typedef struct {
49 uint64_t opaque;
50} llcas_objectid_t;
51
52/**
53 * A loaded CAS object.
54 */
55typedef struct {
56 uint64_t opaque;
57} llcas_loaded_object_t;
58
59/**
60 * Object references for a CAS object.
61 */
62typedef struct {
63 uint64_t opaque_b;
64 uint64_t opaque_e;
65} llcas_object_refs_t;
66
67/**
68 * Return values for a load operation.
69 */
70typedef enum {
71 /**
72 * The object was found.
73 */
74 LLCAS_LOOKUP_RESULT_SUCCESS = 0,
75
76 /**
77 * The object was not found.
78 */
79 LLCAS_LOOKUP_RESULT_NOTFOUND = 1,
80
81 /**
82 * An error occurred.
83 */
84 LLCAS_LOOKUP_RESULT_ERROR = 2,
85} llcas_lookup_result_t;
86
87/**
88 * Callback for \c llcas_cas_load_object_async.
89 *
90 * \param ctx pointer passed through from the \c llcas_cas_load_object_async
91 * call.
92 * \param error message if an error occurred. If set, the memory it points to
93 * needs to be released via \c llcas_string_dispose.
94 */
95typedef void (*llcas_cas_load_object_cb)(void *ctx, llcas_lookup_result_t,
96 llcas_loaded_object_t, char *error);
97
98/**
99 * Callback for \c llcas_actioncache_get_for_digest_async.
100 *
101 * \param ctx pointer passed through from the
102 * \c llcas_actioncache_get_for_digest_async call.
103 * \param error message if an error occurred. If set, the memory it points to
104 * needs to be released via \c llcas_string_dispose.
105 */
106typedef void (*llcas_actioncache_get_cb)(void *ctx, llcas_lookup_result_t,
107 llcas_objectid_t, char *error);
108
109/**
110 * Callback for \c llcas_actioncache_put_for_digest_async.
111 *
112 * \param ctx pointer passed through from the
113 * \c llcas_actioncache_put_for_digest_async call.
114 * \param error message if an error occurred. If set, the memory it points to
115 * needs to be released via \c llcas_string_dispose.
116 */
117typedef void (*llcas_actioncache_put_cb)(void *ctx, bool failed, char *error);
118
119#endif /* LLVM_C_CAS_PLUGINAPI_TYPES_H */
120