From cae4f005e80d47c77405e3bf02eaf5fe3f6941d5 Mon Sep 17 00:00:00 2001 From: Steve Cook Date: Wed, 20 Jul 2022 09:08:54 -0400 Subject: [PATCH] Add TryFrom conversion for FramebufferFormat and CamOutputFormat --- ctru-rs/src/services/cam.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ctru-rs/src/services/cam.rs b/ctru-rs/src/services/cam.rs index cb5d217..ee953f4 100644 --- a/ctru-rs/src/services/cam.rs +++ b/ctru-rs/src/services/cam.rs @@ -1,5 +1,6 @@ use bitflags::bitflags; use ctru_sys::Handle; +use crate::services::gspgpu::FramebufferFormat; pub struct Cam(()); @@ -166,6 +167,28 @@ bitflags! { } } +impl TryFrom for CamOutputFormat { + type Error = (); + + fn try_from(value: FramebufferFormat) -> Result { + match value { + FramebufferFormat::Rgb565 => Ok(CamOutputFormat::RGB_565), + _ => Err(()) + } + } +} + +impl TryFrom for FramebufferFormat { + type Error = (); + + fn try_from(value: CamOutputFormat) -> Result { + match value { + CamOutputFormat::RGB_565 => Ok(FramebufferFormat::Rgb565), + _ => Err(()) + } + } +} + bitflags! { #[derive(Default)] pub struct CamShutterSoundType: u32 {