summaryrefslogtreecommitdiff
path: root/src/v4l2.rs
diff options
context:
space:
mode:
authordyknon dyknonr5fjp2025-02-23 08:33:02 +0900
committerdyknon dyknonr5fjp2025-02-23 08:33:02 +0900
commit31b60ae28e6aff6d23b378cd77e288c96c7db148 (patch)
treedc3c0ede85e0fb23cdc2a3fd0dc0282c60bbc866 /src/v4l2.rs
parent551373efc490b8d570254ee46b09d4e953e2a2d4 (diff)
abstruction
Diffstat (limited to 'src/v4l2.rs')
-rw-r--r--src/v4l2.rs17
1 files changed, 16 insertions, 1 deletions
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<str> for ImageFormat{
+ fn eq(&self, other: &str) -> bool{
+ Into::<ImageFormat>::into(other) == *self
+ }
+}
+impl PartialEq<ImageFormat> for str{
+ fn eq(&self, other: &ImageFormat) -> bool{
+ Into::<ImageFormat>::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))