kotauskas / interprocess

Multifunctional cross-platform interprocess communication toolkit for Rust.
Apache License 2.0
389 stars 47 forks source link

Implement clone for LocalSocketStream #7

Closed asv7c2 closed 5 months ago

asv7c2 commented 3 years ago

Is your feature request related to a problem? Please describe. It is impossible to share stream between BufReader and BufWriter. Rust std TcpStream have try_clone for this.

Describe the solution you'd like Implement clone for LocalSocketStream.

csunday95 commented 2 years ago

+1 for this, worth noting that the standard library UnixStream also has try_clone() support for unix domain sockets. I haven't looked too closely yet, but it may be possible to replace the current local_socket unix implementation with a wrapper for the standard library one.

kotauskas commented 2 years ago

Not going to replace existing code with a wrapper for standard library Ud-sockets since those don't fully support ancillary data: there is nightly support for receiving it (and our MSRV is 1.46 for the 1.x release line), but it seems shady to me because it exposes raw byte buffers which are prone to alignment issues, which is what led me to disable ancillary data for the upcoming 1.2.0 in favor of an API rework in 2.0.0.

Injecting the ancillary data functionality into a wrapper is more trouble than just keeping independent code, since it's not particularly complex anyway (pretty simple adaptors for read(3) and write(3)), save for the ancillary data implementation (which is the exact thing that std doesn't adequately provide yet).

That being said, I will definitely snoop into std's implementation for .try_clone() and do a similar thing here for all platforms, not just Unix, after I'm done with the Tokio support that I'm currently implementing for 1.2.0, which is admittedly going rather slowly due to personal time management struggles, but I absolutely haven't abandoned maintenance of the crate and will release the next update in a finite amount of time along with providing bug fixes if any are found.

kotauskas commented 1 year ago

2f7ce61 and a few other adjacent commits add TryClone on the Unix side of things. Windows support will follow soon. I will only close the issue when 2.0.0 is released, introducing this feature to the Crates.io release.

iXialumy commented 12 months ago

Is there any update on this, especially the windows side? In case this needs help implementing, I would love to help, since this is a feature, that I would very much like to use.

kotauskas commented 5 months ago

Turns out, this has been resolved for a while and I forgot to close this during the 2.0.0 release. Here it is.