21 lines
517 B
Rust
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()
|
|
}
|
|
}
|