use a simple constant

This commit is contained in:
Dustin J. Mitchell
2022-01-28 03:51:58 +00:00
parent b3cbec1af3
commit 82459e699c
2 changed files with 9 additions and 6 deletions

View File

@@ -33,10 +33,9 @@ pub extern "C" fn tc_uuid_nil() -> TCUuid {
Uuid::nil().into() Uuid::nil().into()
} }
/// Length, in bytes, of a C string containing a TCUuid. // NOTE: this must be a simple constant so that cbindgen can evaluate it
// TODO: why not a const? /// Length, in bytes, of the string representation of a UUID (without NUL terminator)
#[no_mangle] pub const TC_UUID_STRING_BYTES: usize = 36;
pub static TC_UUID_STRING_BYTES: usize = ::uuid::adapter::Hyphenated::LENGTH;
/// Write the string representation of a TCUuid into the given buffer, which must be /// Write the string representation of a TCUuid into the given buffer, which must be
/// at least TC_UUID_STRING_BYTES long. No NUL terminator is added. /// at least TC_UUID_STRING_BYTES long. No NUL terminator is added.

View File

@@ -1,5 +1,11 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#define TC_UUID_STRING_BYTES 36
/**
* Length, in bytes, of the string representation of a UUID (without NUL terminator)
*/
#define TC_UUID_STRING_BYTES 36
/** /**
* A result combines a boolean success value with * A result combines a boolean success value with
@@ -74,8 +80,6 @@ typedef struct TCUuid {
extern "C" { extern "C" {
#endif // __cplusplus #endif // __cplusplus
extern const size_t TC_UUID_STRING_BYTES;
/** /**
* Create a new TCReplica with an in-memory database. The contents of the database will be * Create a new TCReplica with an in-memory database. The contents of the database will be
* lost when it is freed. * lost when it is freed.