From 31b60ae28e6aff6d23b378cd77e288c96c7db148 Mon Sep 17 00:00:00 2001 From: dyknon Date: Sun, 23 Feb 2025 08:33:02 +0900 Subject: abstruction --- src/v4l2.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/v4l2.rs') diff --git a/src/v4l2.rs b/src/v4l2.rs index 96cc356..0f22aba 100644 --- a/src/v4l2.rs +++ b/src/v4l2.rs @@ -148,6 +148,16 @@ impl Debug for ImageFormat{ if self.be(){ ":be" }else{ "" }) } } +impl PartialEq for ImageFormat{ + fn eq(&self, other: &str) -> bool{ + Into::::into(other) == *self + } +} +impl PartialEq for str{ + fn eq(&self, other: &ImageFormat) -> bool{ + Into::::into(self) == *other + } +} #[derive(Copy, Clone)] pub struct BufAttrs{ @@ -194,6 +204,8 @@ pub struct Device{ cap: v4l2::v4l2_capability, io_capture: IoMethod, } +// Safe to Send while *mut u8 in IoMethod is never be copied. +unsafe impl Send for Device{} macro_rules! /* unsafe */ mk_ioctl_getter{ ($name:ident, $type:ty, $op:expr; $($qn:ident: $qt:ty),*) => { @@ -325,7 +337,10 @@ impl Device{ unsafe{ Self::unmap_bufs(bufs) }; panic!("mmap: {:?}", IoError::last_os_error()); } - bufs.push(MmappedBuffer{ptr: ptr as *mut u8, length: bufr.length}); + bufs.push(MmappedBuffer{ + ptr: ptr as *mut u8, + length: bufr.length, + }); } Ok(IoMethod::Mmap(bufs)) -- cgit v1.2.3