Open Abscissa opened 10 years ago
I guess it should be possible to have a proxy class derive from std.socket.Socket
or std.socket.TcpSocket
and override all methods, so that the external library wouldn't even have to use a template.
The question would then just be how to handle things like connectTCP
(or listenTCP
) - have the user provide an explicit "factory" callback? Also, there are still other things like the connection pool, which are rather vibe.d specific, but might be (desirable as) an integral part of the API.
Currently, libraries which use sockets (such as DB clients like mysql-native) cannot support both Vibe sockets and Phobos sockets (for non-Vibe users) without writing their own wrappers and creating optional dependencies on Vibe.d (and AIUI, dub doesn't even fully support optional dependencies yet, which poses an additional issue for library authors).
Vibe.d could use a type which wraps vibe's sockets into a phobos-compatible API. This way, libraries which use sockets would be able to support both Vibe/Phobos sockets simply by simply templating on socket type, and won't even need to include any direct or optional dependency on vibe.d at all (it would be left completely up the the library's user whether or not to depend on vibe.d and use its sockets).