Skip to content

Commit

Permalink
Improve docs for loader traits
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Sep 14, 2023
1 parent 9401555 commit c8815f0
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions crates/egui/src/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ pub use crate::generate_loader_id;

pub type BytesLoadResult = Result<BytesPoll>;

/// 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.
Expand Down Expand Up @@ -305,7 +306,7 @@ pub enum ImagePoll {

pub type ImageLoadResult = Result<ImagePoll>;

/// 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 {
Expand Down Expand Up @@ -420,7 +421,14 @@ impl TexturePoll {

pub type TextureLoadResult = Result<TexturePoll>;

/// 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 {
Expand Down

0 comments on commit c8815f0

Please sign in to comment.