Skip to main content

botan_sys/
errors.rs

1use crate::ffi_types::{c_char, c_int};
2
3#[allow(clippy::upper_case_acronyms)]
4pub type BOTAN_FFI_ERROR = c_int;
5
6pub const BOTAN_FFI_SUCCESS: BOTAN_FFI_ERROR = 0;
7pub const BOTAN_FFI_INVALID_VERIFIER: BOTAN_FFI_ERROR = 1;
8pub const BOTAN_FFI_ERROR_INVALID_INPUT: BOTAN_FFI_ERROR = -1;
9pub const BOTAN_FFI_ERROR_BAD_MAC: BOTAN_FFI_ERROR = -2;
10pub const BOTAN_FFI_ERROR_NO_VALUE: BOTAN_FFI_ERROR = -3;
11pub const BOTAN_FFI_ERROR_INSUFFICIENT_BUFFER_SPACE: BOTAN_FFI_ERROR = -10;
12pub const BOTAN_FFI_ERROR_STRING_CONVERSION_ERROR: BOTAN_FFI_ERROR = -11;
13pub const BOTAN_FFI_ERROR_EXCEPTION_THROWN: BOTAN_FFI_ERROR = -20;
14pub const BOTAN_FFI_ERROR_OUT_OF_MEMORY: BOTAN_FFI_ERROR = -21;
15pub const BOTAN_FFI_ERROR_SYSTEM_ERROR: BOTAN_FFI_ERROR = -22;
16pub const BOTAN_FFI_ERROR_INTERNAL_ERROR: BOTAN_FFI_ERROR = -23;
17pub const BOTAN_FFI_ERROR_BAD_FLAG: BOTAN_FFI_ERROR = -30;
18pub const BOTAN_FFI_ERROR_NULL_POINTER: BOTAN_FFI_ERROR = -31;
19pub const BOTAN_FFI_ERROR_BAD_PARAMETER: BOTAN_FFI_ERROR = -32;
20pub const BOTAN_FFI_ERROR_KEY_NOT_SET: BOTAN_FFI_ERROR = -33;
21pub const BOTAN_FFI_ERROR_INVALID_KEY_LENGTH: BOTAN_FFI_ERROR = -34;
22pub const BOTAN_FFI_ERROR_INVALID_OBJECT_STATE: BOTAN_FFI_ERROR = -35;
23pub const BOTAN_FFI_ERROR_OUT_OF_RANGE: BOTAN_FFI_ERROR = -36;
24pub const BOTAN_FFI_ERROR_NOT_IMPLEMENTED: BOTAN_FFI_ERROR = -40;
25pub const BOTAN_FFI_ERROR_INVALID_OBJECT: BOTAN_FFI_ERROR = -50;
26pub const BOTAN_FFI_ERROR_TLS_ERROR: BOTAN_FFI_ERROR = -75;
27pub const BOTAN_FFI_ERROR_HTTP_ERROR: BOTAN_FFI_ERROR = -76;
28pub const BOTAN_FFI_ERROR_ROUGHTIME_ERROR: BOTAN_FFI_ERROR = -77;
29pub const BOTAN_FFI_ERROR_TPM_ERROR: BOTAN_FFI_ERROR = -78;
30pub const BOTAN_FFI_ERROR_UNKNOWN_ERROR: BOTAN_FFI_ERROR = -100;
31
32/// Not an error code returned by Botan itself.
33///
34/// This value is returned by `botan-sys` when the requested FFI function is
35/// not provided by the Botan library this program is using: either because
36/// the headers found at build time predate the function, or (with dynamic
37/// loading) because the loaded library does not export the symbol.
38///
39/// The value is chosen well outside the range of codes used by Botan.
40pub const BOTAN_FFI_ERROR_FUNCTION_NOT_AVAILABLE: BOTAN_FFI_ERROR = -1000;
41
42/// Not an error code returned by Botan itself.
43///
44/// This value is returned by `botan-sys` when the Botan shared library could
45/// not be loaded at runtime. It is only ever returned when the
46/// `dynamic-loading` feature is in use.
47pub const BOTAN_FFI_ERROR_LIBRARY_NOT_LOADED: BOTAN_FFI_ERROR = -1001;
48
49botan_ffi_functions! {
50
51    pub fn botan_error_description(err: BOTAN_FFI_ERROR) -> *const c_char = core::ptr::null();
52
53    #[cfg(botan_ffi_20230403)]
54    pub fn botan_error_last_exception_message() -> *const c_char = core::ptr::null();
55
56}