Closed
Description
Hello! Thank you for the great library I use Nix for all my projects.
I am trying to call nix::sys::statvfs::fstatvfs
with signature: pub fn fstatvfs<T: AsRawFd>(fd: &T) -> Result<Statvfs>
. I have a RawFd:
let fdref: RawFd = ...;
match nix::sys::statvfs::fstatvfs(& fdref) {
...
}
Error:
error[E0277]: the trait bound `i32: std::os::unix::io::AsRawFd` is not satisfied
--> src/detfs.rs:992:15
|
992 | match nix::sys::statvfs::fstatvfs(& fdref) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::os::unix::io::AsRawFd` is not implemented for `i32`
|
= note: required by `nix::sys::statvfs::fstatvfs`
So it seems I cannot use a RawFd to call a function with T: AsRawFd trait bound?
I ended up wrapping my RawFd in a struct which implemented AsRawFd:
struct Fd(RawFd);
use std::os::unix::io::AsRawFd;
impl AsRawFd for Fd {
fn as_raw_fd(&self) -> RawFd {
self.0
}
}
Which works, but is really weird to have to do. Am I missing something?
Metadata
Metadata
Assignees
Labels
No labels