tormol / uds

A unix domain sockets Rust library
Apache License 2.0
21 stars 9 forks source link

Replacing RawFd with OwnedFd for compatibility with nix crate #24

Closed eesekaj closed 2 weeks ago

eesekaj commented 2 weeks ago

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.

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

Tested with default features on GNU/Linux.