I'm looking for best practice defining a project structure in Rust. Let's say I have a project that consists of a client and a server component, and they share some functionality I'd like to move to a separate common library. So all in all, like this:
my_awesome_project
- common [library]
- client [binary] - uses common
- server [binary] - uses common
Obviously, all methods in the common
crate used in either client
or server
must be public. However, I would like to avoid anyone who has the client
binary (not the code) being able to call methods from common
. Is that possible somehow?
I come from C# background, where common
would be a DLL exposing public methods, easily callable. I've read that Rust uses static linking by default, but in my understanding, that does not provide what I am looking for.
And yes, I could double the common
code in a private module for both server
and client
, but that's not optimal either.