lemunozm / message-io

Fast and easy-to-use event-driven network library.
Apache License 2.0
1.12k stars 75 forks source link

Trait implementation of adapters that cannot accept a socket address? #171

Closed javaarchive closed 5 months ago

javaarchive commented 5 months ago

A bit new to rust, is there any consideration to how transports can be implemented to take in something that is not of SocketAddr type? I am attempting to implement a unix socket adapter and it takes in a path instead of SocketAddr so my current method will likely ignore the SocketAddr but it will still have to be passed.

lemunozm commented 5 months ago

You have a RemoteAddr for those cases; could that be useful? Currently, it supports 2 variants but new ones can be added

EDIT. Never mind, you refer to to the one in ConnectionInfo, right?

javaarchive commented 5 months ago

Basically here the implementation of fn listen_with(config: TransportListen, addr: SocketAddr) takes in SocketAddr which only seems to have IPv4 and IPv6 variants and unix sockets may want to be binded to a file path but for now I am ignoring this parameter initially. image As for fixing the ConnectionInfo that is another issue that I am looking into.

javaarchive commented 5 months ago

I'm going to close this since it seems like on my experiment with a enum that goes between the address types, the SocketAddr for unix sockets is really bad as it doesn't implement any basic traits like Eq or Clone which are needed here even though their underlying types are trivial to derive it for. Likely just going to keep a personal branch of this project that uses a fork of mio for the ugly solution if I need it.