lucab / libsystemd-rs

A pure-Rust client library to work with systemd
https://crates.io/crates/libsystemd
Other
106 stars 19 forks source link

Split up into multiple subcrates #106

Closed swsnr closed 1 year ago

swsnr commented 2 years ago

Hey @lucab,

this crate became quite big; it has accumulated a few different features already, and got quite a few dependencies.

How about splitting it up into multiple subcrates which allows downstream users to pick only parts of this crate to reduce the amount of dependencies?

Specifically I'd very much like to move the contents of logging into a separate crate to avoid pulling in e.g. nom just for writing to the systemd journal, and we could perhaps also join forces with the author of sd_notify or just reexport sd_notify.

What do you think?

lucab commented 2 years ago

Good question. My personal feedback is nuanced: some changes are net-positive, some others come with too much of a drawback.

Here is an initial assorted list of thoughts:

swsnr commented 2 years ago

Oh, we do have quite different opinions indeed :see_no_evil:

I'm careful with dependencies, and I'd trade a dependency the size of nix for half a dozen trivial unsafe calls any time :slightly_smiling_face: I'd not try to get rid of serde or nom for sure, but if I can get rid of nix with some trivial libc wrappers I think it's a positive change :slightly_smiling_face:

I believe that reducing dependencies helps; if I use but a very small subset of a dependency (as we do with nix here) I tend to prefer copying selective parts over bringing in a huge amount of unused code, which nonetheless adds to build times. I hate to pay for transitive dependencies of parts I don't even use (e.g. nom and serde if all I use is logging.rs :slightly_smiling_face: ).

I also tend to believe that splitting into a workspace of loosly coupled (I mean the logging module doesn't really have any relation to the sysusers stuff, does it?) subcrates is much simpler than feature-guarding individual modules. Dependencies are pretty easy to understand in Rust, but cargo features lead to an explosion of possible build states and outcomes which is hard to manage in my experience.

I think we'll probably need to agree to disagree here :see_no_evil: If you like we can close this issue; I'll probably just copy the relevant parts of this crate to my projects then (which is totally fine with me, after all the journal interface is pretty much set in stone and I don't expect much changes there :slightly_smiling_face: )

swsnr commented 1 year ago

@lucab I'm closing this issue, because I don't think we'll be doing it 😄 and I'm just clearing out my issues list 😇