From c8815f0ba4e2490bbb3b7a536420226fa6f4e6df Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Thu, 14 Sep 2023 13:35:41 +0200 Subject: [PATCH] Improve docs for loader traits --- crates/egui/src/load.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/crates/egui/src/load.rs b/crates/egui/src/load.rs index 2bd6c63225b..63fec357324 100644 --- a/crates/egui/src/load.rs +++ b/crates/egui/src/load.rs @@ -238,7 +238,8 @@ pub use crate::generate_loader_id; pub type BytesLoadResult = Result; -/// Represents a loader capable of loading raw unstructured bytes. +/// Represents a loader capable of loading raw unstructured bytes from somewhere, +/// e.g. from disk or network. /// /// It should also provide any subsequent loaders a hint for what the bytes may /// represent using [`BytesPoll::Ready::mime`], if it can be inferred. @@ -305,7 +306,7 @@ pub enum ImagePoll { pub type ImageLoadResult = Result; -/// Represents a loader capable of loading a raw image. +/// An `ImageLoader` decodes raw bytes into a [`ColorImage`]. /// /// Implementations are expected to cache at least each `URI`. pub trait ImageLoader { @@ -420,7 +421,14 @@ impl TexturePoll { pub type TextureLoadResult = Result; -/// Represents a loader capable of loading a full texture. +/// A `TextureLoader` uploads a [`ColorImage`] to the GPU, returning a [`SizedTexture`]. +/// +/// `egui` comes with an implementation that uses [`Context::load_texture`], +/// which just asks the egui backend to upload the image to the GPU. +/// +/// You can implement this trait if you do your own uploading of images to the GPU. +/// For instance, you can use this to refer to textures in a game engine that egui +/// doesn't otherwise know about. /// /// Implementations are expected to cache each combination of `(URI, TextureOptions)`. pub trait TextureLoader {