@@ -95,7 +95,7 @@ use std::fs::{read_dir, File, ReadDir};
9595use std:: io:: Read ;
9696use std:: mem;
9797use std:: ops:: Index ;
98- use std:: os:: unix:: io:: { AsRawFd , FromRawFd , RawFd } ;
98+ use std:: os:: unix:: io:: { AsFd , AsRawFd , BorrowedFd , FromRawFd , RawFd } ;
9999use std:: path:: { Path , PathBuf } ;
100100use std:: ptr;
101101use std:: slice;
@@ -335,7 +335,7 @@ pub struct Line {
335335/// Wraps kernel [`struct gpioline_info`].
336336///
337337/// [`struct gpioline_info`]: https://elixir.bootlin.com/linux/v4.9.127/source/include/uapi/linux/gpio.h#L36
338- #[ derive( Debug , Clone ) ]
338+ #[ derive( Debug ) ]
339339pub struct LineInfo {
340340 line : Line ,
341341 flags : LineFlags ,
@@ -349,6 +349,7 @@ bitflags! {
349349 /// Maps to kernel [`GPIOHANDLE_REQUEST_*`] flags.
350350 ///
351351 /// [`GPIOHANDLE_REQUEST_*`]: https://elixir.bootlin.com/linux/v4.9.127/source/include/uapi/linux/gpio.h#L58
352+ #[ derive( Debug , Clone ) ]
352353 pub struct LineRequestFlags : u32 {
353354 const INPUT = ( 1 << 0 ) ;
354355 const OUTPUT = ( 1 << 1 ) ;
@@ -367,7 +368,7 @@ bitflags! {
367368 pub struct EventRequestFlags : u32 {
368369 const RISING_EDGE = ( 1 << 0 ) ;
369370 const FALLING_EDGE = ( 1 << 1 ) ;
370- const BOTH_EDGES = Self :: RISING_EDGE . bits | Self :: FALLING_EDGE . bits;
371+ const BOTH_EDGES = Self :: RISING_EDGE . bits( ) | Self :: FALLING_EDGE . bits( ) ;
371372 }
372373}
373374
@@ -377,6 +378,7 @@ bitflags! {
377378 /// Maps to kernel [`GPIOLINE_FLAG_*`] flags.
378379 ///
379380 /// [`GPIOLINE_FLAG_*`]: https://elixir.bootlin.com/linux/v4.9.127/source/include/uapi/linux/gpio.h#L29
381+ #[ derive( Debug ) ]
380382 pub struct LineFlags : u32 {
381383 const KERNEL = ( 1 << 0 ) ;
382384 const IS_OUT = ( 1 << 1 ) ;
@@ -572,7 +574,7 @@ impl Line {
572574 consumer : & str ,
573575 ) -> Result < AsyncLineEventHandle > {
574576 let events = self . events ( handle_flags, event_flags, consumer) ?;
575- Ok ( AsyncLineEventHandle :: new ( events) ? )
577+ AsyncLineEventHandle :: new ( events)
576578 }
577579}
578580
@@ -693,7 +695,7 @@ impl LineHandle {
693695
694696 /// Get the flags with which this handle was created
695697 pub fn flags ( & self ) -> LineRequestFlags {
696- self . flags
698+ self . flags . clone ( )
697699 }
698700}
699701
@@ -985,6 +987,14 @@ impl LineEventHandle {
985987 & self . line
986988 }
987989
990+ pub fn file ( & self ) -> & File {
991+ & self . file
992+ }
993+
994+ pub fn file2 ( & mut self ) -> & File {
995+ & self . file
996+ }
997+
988998 /// Helper function which returns the line event if a complete event was read, Ok(None) if not
989999 /// enough data was read or the error returned by `read()`.
9901000 pub ( crate ) fn read_event ( & mut self ) -> std:: io:: Result < Option < LineEvent > > {
@@ -1011,6 +1021,13 @@ impl AsRawFd for LineEventHandle {
10111021 }
10121022}
10131023
1024+ impl AsFd for LineEventHandle {
1025+ /// Gets the raw file descriptor for the `LineEventHandle`.
1026+ fn as_fd ( & self ) -> BorrowedFd < ' _ > {
1027+ self . file . as_fd ( )
1028+ }
1029+ }
1030+
10141031impl Iterator for LineEventHandle {
10151032 type Item = Result < LineEvent > ;
10161033
0 commit comments