Decouple the image Handle type from the iced_native implementation

This commit is contained in:
Olivier Pinon 2021-12-10 20:15:27 +01:00
parent 8cbba94458
commit a7bcd65bb8
4 changed files with 37 additions and 24 deletions

View file

@ -115,10 +115,15 @@ impl std::fmt::Debug for Data {
///
/// [renderer]: crate::renderer
pub trait Renderer: crate::Renderer {
/// The image Handle to be displayed. Iced exposes its own default implementation of a [`Handle`]
///
/// [`Handle`]: Self::Handle
type Handle: Clone + Hash;
/// Returns the dimensions of an image for the given [`Handle`].
fn dimensions(&self, handle: &Handle) -> (u32, u32);
fn dimensions(&self, handle: &Self::Handle) -> (u32, u32);
/// Draws an image with the given [`Handle`] and inside the provided
/// `bounds`.
fn draw(&mut self, handle: Handle, bounds: Rectangle);
fn draw(&mut self, handle: Self::Handle, bounds: Rectangle);
}