On 02-11-22, 21:14, Kent Gibson wrote:
- /// Get the file descriptor associated with the chip.
- ///
- /// The returned file descriptor must not be closed by the caller, else other methods for the
- /// `struct Chip` may fail.
- pub fn fd(&self) -> Result<u32> {
// SAFETY: `gpiod_chip` is guaranteed to be valid here.
let fd = unsafe { gpiod::gpiod_chip_get_fd(self.ichip.chip) };
if fd < 0 {
Err(Error::OperationFailed(
OperationType::ChipGetFd,
errno::errno(),
))
} else {
Ok(fd as u32)
}
- }
Impl AsRawFd, as per Request.
You suggested it for line request earlier and I fixed that.
My bad for not updating this one, I completely missed that we have fd implementation here too :(