Skip to content

Commit 5279863

Browse files
Add missing docs for ImageLoader (#19499)
# Objective Yet another tiny step towards #3492. --------- Co-authored-by: SpecificProtagonist <[email protected]>
1 parent f163649 commit 5279863

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

crates/bevy_image/src/image_loader.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,35 @@ impl ImageLoader {
8181
}
8282
}
8383

84+
/// How to determine an image's format when loading.
8485
#[derive(Serialize, Deserialize, Default, Debug, Clone)]
8586
pub enum ImageFormatSetting {
87+
/// Determine the image format from its file extension.
88+
///
89+
/// This is the default.
8690
#[default]
8791
FromExtension,
92+
/// Declare the image format explicitly.
8893
Format(ImageFormat),
94+
/// Guess the image format by looking for magic bytes at the
95+
/// beginning of its data.
8996
Guess,
9097
}
9198

99+
/// Settings for loading an [`Image`] using an [`ImageLoader`].
92100
#[derive(Serialize, Deserialize, Debug, Clone)]
93101
pub struct ImageLoaderSettings {
102+
/// How to determine the image's format.
94103
pub format: ImageFormatSetting,
104+
/// Specifies whether image data is linear
105+
/// or in sRGB space when this is not determined by
106+
/// the image format.
95107
pub is_srgb: bool,
108+
/// [`ImageSampler`] to use when rendering - this does
109+
/// not affect the loading of the image data.
96110
pub sampler: ImageSampler,
111+
/// Where the asset will be used - see the docs on
112+
/// [`RenderAssetUsages`] for details.
97113
pub asset_usage: RenderAssetUsages,
98114
}
99115

@@ -108,11 +124,14 @@ impl Default for ImageLoaderSettings {
108124
}
109125
}
110126

127+
/// An error when loading an image using [`ImageLoader`].
111128
#[non_exhaustive]
112129
#[derive(Debug, Error)]
113130
pub enum ImageLoaderError {
114-
#[error("Could load shader: {0}")]
131+
/// An error occurred while trying to load the image bytes.
132+
#[error("Failed to load image bytes: {0}")]
115133
Io(#[from] std::io::Error),
134+
/// An error occurred while trying to decode the image bytes.
116135
#[error("Could not load texture file: {0}")]
117136
FileTexture(#[from] FileTextureError),
118137
}
@@ -170,7 +189,7 @@ impl AssetLoader for ImageLoader {
170189

171190
/// An error that occurs when loading a texture from a file.
172191
#[derive(Error, Debug)]
173-
#[error("Error reading image file {path}: {error}, this is an error in `bevy_render`.")]
192+
#[error("Error reading image file {path}: {error}.")]
174193
pub struct FileTextureError {
175194
error: TextureError,
176195
path: String,

0 commit comments

Comments
 (0)