Add OrientationType type
This commit is contained in:
@ -8,8 +8,9 @@ mod endian_type;
|
||||
mod filter_type;
|
||||
mod gravity_type;
|
||||
mod interlace_type;
|
||||
mod pixel_interpolate_method;
|
||||
mod metric_type;
|
||||
mod orientation_type;
|
||||
mod pixel_interpolate_method;
|
||||
mod resource_type;
|
||||
|
||||
pub use self::alpha_channel_option::AlphaChannelOption;
|
||||
@ -22,6 +23,7 @@ pub use self::endian_type::EndianType;
|
||||
pub use self::filter_type::FilterType;
|
||||
pub use self::gravity_type::GravityType;
|
||||
pub use self::interlace_type::InterlaceType;
|
||||
pub use self::pixel_interpolate_method::PixelInterpolateMethod;
|
||||
pub use self::metric_type::MetricType;
|
||||
pub use self::orientation_type::OrientationType;
|
||||
pub use self::pixel_interpolate_method::PixelInterpolateMethod;
|
||||
pub use self::resource_type::ResourceType;
|
||||
|
||||
44
src/types/orientation_type.rs
Normal file
44
src/types/orientation_type.rs
Normal file
@ -0,0 +1,44 @@
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum OrientationType {
|
||||
Undefined = bindings::OrientationType_UndefinedOrientation,
|
||||
TopLeft = bindings::OrientationType_TopLeftOrientation,
|
||||
TopRight = bindings::OrientationType_TopRightOrientation,
|
||||
BottomRight = bindings::OrientationType_BottomRightOrientation,
|
||||
BottomLeft = bindings::OrientationType_BottomLeftOrientation,
|
||||
LeftTop = bindings::OrientationType_LeftTopOrientation,
|
||||
RightTop = bindings::OrientationType_RightTopOrientation,
|
||||
RightBottom = bindings::OrientationType_RightBottomOrientation,
|
||||
LeftBottom = bindings::OrientationType_LeftBottomOrientation,
|
||||
}
|
||||
|
||||
impl Default for OrientationType {
|
||||
fn default() -> Self {
|
||||
return OrientationType::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<OrientationType> for bindings::OrientationType {
|
||||
fn from(value: OrientationType) -> Self {
|
||||
return value as bindings::OrientationType;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::OrientationType> for OrientationType {
|
||||
fn from(value: bindings::OrientationType) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `OrientationType` has the same repr as `bindings::OrientationType` - u32
|
||||
*
|
||||
* If `value` is less than LeftBottom than it is in the vaild range and can be safely
|
||||
* reinterpreted as `OrientationType`
|
||||
*/
|
||||
if value <= bindings::OrientationType_LeftBottomOrientation {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return OrientationType::default();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user