servicepoint-binding-uniffi/src/brightness.rs
Vinzenz Schroeter f4c7519658 export some builtin traits,
brightness conversion fails for invalid values,

macros for wrapping attrs
2025-09-28 23:14:11 +02:00

21 lines
517 B
Rust

use crate::errors::ServicePointError;
use crate::UniffiCustomTypeConverter;
use servicepoint::Brightness;
uniffi::custom_type!(Brightness, u8);
impl UniffiCustomTypeConverter for Brightness {
type Builtin = u8;
fn into_custom(val: Self::Builtin) -> uniffi::Result<Self>
where
Self: Sized,
{
Ok(Brightness::try_from(val)
.map_err(|value| ServicePointError::InvalidBrightness { value })?)
}
fn from_custom(obj: Self) -> Self::Builtin {
obj.into()
}
}