diff --git a/atrium-api/src/types/integer.rs b/atrium-api/src/types/integer.rs index 7d4fe7cb..627384db 100644 --- a/atrium-api/src/types/integer.rs +++ b/atrium-api/src/types/integer.rs @@ -40,6 +40,12 @@ macro_rules! uint { } } + impl From<$lim> for $primitive { + fn from(value: $lim) -> Self { + value.0 + } + } + /// An unsigned integer with a minimum value of 1 and a maximum value of `MAX`. #[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize)] #[repr(transparent)] @@ -76,6 +82,18 @@ macro_rules! uint { } } + impl From<$lim_nz> for $nz { + fn from(value: $lim_nz) -> Self { + value.0 + } + } + + impl From<$lim_nz> for $primitive { + fn from(value: $lim_nz) -> Self { + value.0.into() + } + } + /// An unsigned integer with a minimum value of `MIN` and a maximum value of `MAX`. /// /// `MIN` must be non-zero. @@ -119,6 +137,18 @@ macro_rules! uint { Self::new(value).map_err(D::Error::custom) } } + + impl From<$bounded> for $nz { + fn from(value: $bounded) -> Self { + value.0 + } + } + + impl From<$bounded> for $primitive { + fn from(value: $bounded) -> Self { + value.0.into() + } + } }; }