1use crate::bindings::*;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
4#[repr(u8)]
5pub enum ErrorType {
6 TextMeasurementFunctionNotProvided =
9 Clay_ErrorType_CLAY_ERROR_TYPE_TEXT_MEASUREMENT_FUNCTION_NOT_PROVIDED,
10 ArenaCapacityExceeded = Clay_ErrorType_CLAY_ERROR_TYPE_ARENA_CAPACITY_EXCEEDED,
11 ElementsCapacityExceeded = Clay_ErrorType_CLAY_ERROR_TYPE_ELEMENTS_CAPACITY_EXCEEDED,
12 TextMeasurementCapacityExceeded =
13 Clay_ErrorType_CLAY_ERROR_TYPE_TEXT_MEASUREMENT_CAPACITY_EXCEEDED,
14 DuplicateId = Clay_ErrorType_CLAY_ERROR_TYPE_DUPLICATE_ID,
16 FloatingContainerParentNotFound =
19 Clay_ErrorType_CLAY_ERROR_TYPE_FLOATING_CONTAINER_PARENT_NOT_FOUND,
20 InternalError = Clay_ErrorType_CLAY_ERROR_TYPE_INTERNAL_ERROR,
21}
22
23#[derive(Debug, Clone, Copy)]
24pub struct Error<'a> {
25 pub type_: ErrorType,
26 pub text: &'a str,
27}
28
29impl From<Clay_ErrorData> for Error<'_> {
30 fn from(value: Clay_ErrorData) -> Self {
31 Self {
32 type_: unsafe { core::mem::transmute::<u8, ErrorType>(value.errorType) },
33 text: value.errorText.into(),
34 }
35 }
36}