uds icon indicating copy to clipboard operation
uds copied to clipboard

Replacing RawFd with OwnedFd for compatibility with nix crate

Open eesekaj opened this issue 1 year ago • 0 comments

Hello,

Please find attached a pull request where the following changes were made:

  1. RawFd was replaced in favor of OwnedFd. The nix crate is no longer accepts the RawFd as argument and requires the BorrowedFd to be passed as argument. OwnedFd is:

An owned file descriptor.

This closes the file descriptor on drop. It is guaranteed that nobody else will close the file descriptor.

This uses repr(transparent) and has the representation of a host file descriptor, so it can be used in FFI in places where a file descriptor is passed as a consumed argument or returned as an owned value, and it never has the value -1.

You can use AsFd::as_fd to obtain a BorrowedFd.

  1. Updated the crates versions. This is not necessary, but this crate forces to download additional dependencies.
  2. Added a function "send_flags" in "UnixSeqpacketConn". + impl AsFd and commented out the impl Drop (as OwnedFd should close the socket).
  3. Removed unused import.

Tested with default features on GNU/Linux.

eesekaj avatar Oct 28 '24 01:10 eesekaj