RustDDS
RustDDS copied to clipboard
Considering refactoring to a "workspace" organization
RustDDS is current one BIG crate. This means that when projects rely on RustDDS they must build all the code in one big step. You can increase parallelism of cargo's build, potentially give library users more fine grain access to functionality, and the purpose of dependencies much more clear.
You would start by replacing the root Cargo.toml
with a workspace definition. All the nested crates (I call them subcrates but I don't think that's a popular term) can continue to exist in this repo no problem.
How could you "chunk" up the RustDDS?
/
Cargo.toml # the workspace one
/rustdds-serialization/Cargo.toml
/rustdds-messages/Cargo.toml
/rustdds-network/Cargo.toml
... and so on ...
then in the root Cargo.toml:
[workspace]
default-members = [
"rustdds-serialization",
"rustdds-messages,
"rustdds-network"
]
and rustdds-serialization/Cargo.toml
:
[package]
name = "rustdds-serialization
version = "0.1.0"
authors = ["..."]
edition = "2021"
[dependencies]
# only the SPECIFIC dependencies for the serialization functionality
and cargo can roll up all the transitive dependencies of your subcrates and create a Cargo.lock
at the root.
All my rust projects have transitioned to this style, it makes builds much faster and small crates have nice little test suites.
That is a good suggestion.
However, before doing this, the RustDDS codebase needs to be reviewed and quite likely some code should be moved between current modules to make a more sensible module structure. Otherwise, the dependencies between subcrates could end up very convoluted.
Wrote down some reorganization ideas in #184 .