linebender / piet

An abstraction for 2D graphics.
Apache License 2.0
1.23k stars 95 forks source link

Allow IntoBrush to be implemented by outside crates #552

Closed notgull closed 1 year ago

notgull commented 1 year ago

Hello! Thanks for making this crate. So far, it's the most comprehensive graphics API that I've been able to find for Rust.

I'm currently working on a standalone Piet implementation. I have a Brush structure in this case that needs to implement IntoBrush. According to piet's docs, as well as the fact that IntoBrush's methods are doc(hidden), IntoBrush isn't meant to be implemented outside of this crate (although piet-cairo breaks this rule). Right now, I implement IntoBrush in spite of this. However, it would be nice if there was a mechanism for implementing IntoBrush on my crate's types.

Using PaintBrush is not an option in this case. There are some resources that I need to cache in the brush handle for the sake of performance.

xStrom commented 1 year ago

Looks like IntoBrush is implemented in all the backends, not just piet-cairo. So I guess the internal trait comment includes the backend crates in its definition of internal.

You say you're implementintg IntoBrush already, so it's not clear to me what mechanism is missing.

notgull commented 1 year ago

The thing is, the make_brush function is doc(hidden). While I can still implement it, it implies that the trait is semver-unstable. If this method were exposed publicly it would close this issue.

xStrom commented 1 year ago

Docs like that are optimized for Piet users, not Piet backend developers.

As for semver compatability, we follow the general semver rules. Whichs means we might break absolutely anything, but we will increase the version number accordingly.

More practically speaking, Piet is in maintenance mode so that trait is unlikely to change.

notgull commented 1 year ago

Okay, I'll take that as "the doc(hidden) has no intrinsic meaning". Thanks! I'll close this issue now.