RazrFalcon / resvg

An SVG rendering library.
Mozilla Public License 2.0
2.74k stars 220 forks source link

Re-Export Required Dependencies #504

Closed sdedovic closed 2 years ago

sdedovic commented 2 years ago

Is there a reason why types used in the public API from external crates are not re-exported?

For example, the render function:

pub fn render(
    tree: &usvg::Tree,
    fit_to: usvg::FitTo,
    transform: tiny_skia::Transform,
    pixmap: tiny_skia::PixmapMut,
) -> Option<()>

has Types from usvg and tiny_skia. In order to use this API, I need to add these two libraries to my Cargo.toml. Presumably I also need to keep version in sync in case of incompatible changes.

I think it would make a log more sense to re-export these types under resvg::usvg::* and resvg::tiny_skia::*. That way I only the resvg library and I get the transitive dependencies for free.

I am happy to put out a PR with this change. Just didn't see any discussion about it and I don't want to put the work in if it's unwanted.

RazrFalcon commented 2 years ago

For now, this is simply a stylistic choice. I would accept a PR if you would be able to provide a link to some official Rust guidelines explaining how this particular case should be handled.

filips123 commented 2 years ago

There have been some discussions about this in the past, but nothing concrete was decided. There is also Effective Rust guide which recommends re-exporting dependencies, although it is not official. (And I would also prefer re-exported dependencies for the same reasons as above.)