mirror of
https://github.com/bevyengine/bevy
synced 2024-11-25 14:10:19 +00:00
Remove thiserror
from bevy_image
(#15771)
# Objective - Contributes to #15460 ## Solution - Removed `thiserror` from `bevy_image`
This commit is contained in:
parent
9366b95006
commit
1f4adec7df
5 changed files with 47 additions and 34 deletions
|
@ -52,7 +52,11 @@ bitflags = { version = "2.3", features = ["serde"] }
|
||||||
bytemuck = { version = "1.5" }
|
bytemuck = { version = "1.5" }
|
||||||
wgpu = { version = "22", default-features = false }
|
wgpu = { version = "22", default-features = false }
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
thiserror = "1.0"
|
derive_more = { version = "1", default-features = false, features = [
|
||||||
|
"error",
|
||||||
|
"from",
|
||||||
|
"display",
|
||||||
|
] }
|
||||||
futures-lite = "2.0.1"
|
futures-lite = "2.0.1"
|
||||||
ddsfile = { version = "0.5.2", optional = true }
|
ddsfile = { version = "0.5.2", optional = true }
|
||||||
ktx2 = { version = "0.3.0", optional = true }
|
ktx2 = { version = "0.3.0", optional = true }
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::{Image, TextureFormatPixelInfo};
|
use crate::{Image, TextureFormatPixelInfo};
|
||||||
use bevy_asset::{io::Reader, AssetLoader, LoadContext, RenderAssetUsages};
|
use bevy_asset::{io::Reader, AssetLoader, LoadContext, RenderAssetUsages};
|
||||||
|
use derive_more::derive::{Display, Error, From};
|
||||||
use image::ImageDecoder;
|
use image::ImageDecoder;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use thiserror::Error;
|
|
||||||
use wgpu::{Extent3d, TextureDimension, TextureFormat};
|
use wgpu::{Extent3d, TextureDimension, TextureFormat};
|
||||||
|
|
||||||
/// Loads EXR textures as Texture assets
|
/// Loads EXR textures as Texture assets
|
||||||
|
@ -18,13 +18,11 @@ pub struct ExrTextureLoaderSettings {
|
||||||
|
|
||||||
/// Possible errors that can be produced by [`ExrTextureLoader`]
|
/// Possible errors that can be produced by [`ExrTextureLoader`]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error, Display, From)]
|
||||||
#[cfg(feature = "exr")]
|
#[cfg(feature = "exr")]
|
||||||
pub enum ExrTextureLoaderError {
|
pub enum ExrTextureLoaderError {
|
||||||
#[error(transparent)]
|
Io(std::io::Error),
|
||||||
Io(#[from] std::io::Error),
|
ImageError(image::ImageError),
|
||||||
#[error(transparent)]
|
|
||||||
ImageError(#[from] image::ImageError),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AssetLoader for ExrTextureLoader {
|
impl AssetLoader for ExrTextureLoader {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use crate::{Image, TextureFormatPixelInfo};
|
use crate::{Image, TextureFormatPixelInfo};
|
||||||
use bevy_asset::RenderAssetUsages;
|
use bevy_asset::RenderAssetUsages;
|
||||||
use bevy_asset::{io::Reader, AssetLoader, LoadContext};
|
use bevy_asset::{io::Reader, AssetLoader, LoadContext};
|
||||||
|
use derive_more::derive::{Display, Error, From};
|
||||||
use image::DynamicImage;
|
use image::DynamicImage;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use thiserror::Error;
|
|
||||||
use wgpu::{Extent3d, TextureDimension, TextureFormat};
|
use wgpu::{Extent3d, TextureDimension, TextureFormat};
|
||||||
|
|
||||||
/// Loads HDR textures as Texture assets
|
/// Loads HDR textures as Texture assets
|
||||||
|
@ -16,12 +16,12 @@ pub struct HdrTextureLoaderSettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error, Display, From)]
|
||||||
pub enum HdrTextureLoaderError {
|
pub enum HdrTextureLoaderError {
|
||||||
#[error("Could load texture: {0}")]
|
#[display("Could load texture: {_0}")]
|
||||||
Io(#[from] std::io::Error),
|
Io(std::io::Error),
|
||||||
#[error("Could not extract image: {0}")]
|
#[display("Could not extract image: {_0}")]
|
||||||
Image(#[from] image::ImageError),
|
Image(image::ImageError),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AssetLoader for HdrTextureLoader {
|
impl AssetLoader for HdrTextureLoader {
|
||||||
|
|
|
@ -11,8 +11,8 @@ use bevy_math::{AspectRatio, UVec2, UVec3, Vec2};
|
||||||
use bevy_reflect::std_traits::ReflectDefault;
|
use bevy_reflect::std_traits::ReflectDefault;
|
||||||
use bevy_reflect::Reflect;
|
use bevy_reflect::Reflect;
|
||||||
use core::hash::Hash;
|
use core::hash::Hash;
|
||||||
|
use derive_more::derive::{Display, Error, From};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use thiserror::Error;
|
|
||||||
use wgpu::{Extent3d, TextureDimension, TextureFormat, TextureViewDescriptor};
|
use wgpu::{Extent3d, TextureDimension, TextureFormat, TextureViewDescriptor};
|
||||||
pub trait BevyDefault {
|
pub trait BevyDefault {
|
||||||
fn bevy_default() -> Self;
|
fn bevy_default() -> Self;
|
||||||
|
@ -1535,39 +1535,48 @@ pub enum TranscodeFormat {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An error that occurs when accessing specific pixels in a texture
|
/// An error that occurs when accessing specific pixels in a texture
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Display, Debug)]
|
||||||
pub enum TextureAccessError {
|
pub enum TextureAccessError {
|
||||||
#[error("out of bounds (x: {x}, y: {y}, z: {z})")]
|
#[display("out of bounds (x: {x}, y: {y}, z: {z})")]
|
||||||
OutOfBounds { x: u32, y: u32, z: u32 },
|
OutOfBounds { x: u32, y: u32, z: u32 },
|
||||||
#[error("unsupported texture format: {0:?}")]
|
#[display("unsupported texture format: {_0:?}")]
|
||||||
|
#[error(ignore)]
|
||||||
UnsupportedTextureFormat(TextureFormat),
|
UnsupportedTextureFormat(TextureFormat),
|
||||||
#[error("attempt to access texture with different dimension")]
|
#[display("attempt to access texture with different dimension")]
|
||||||
WrongDimension,
|
WrongDimension,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An error that occurs when loading a texture
|
/// An error that occurs when loading a texture
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Display, Debug, From)]
|
||||||
|
#[error(ignore)]
|
||||||
pub enum TextureError {
|
pub enum TextureError {
|
||||||
#[error("invalid image mime type: {0}")]
|
#[display("invalid image mime type: {_0}")]
|
||||||
|
#[from(ignore)]
|
||||||
InvalidImageMimeType(String),
|
InvalidImageMimeType(String),
|
||||||
#[error("invalid image extension: {0}")]
|
#[display("invalid image extension: {_0}")]
|
||||||
|
#[from(ignore)]
|
||||||
InvalidImageExtension(String),
|
InvalidImageExtension(String),
|
||||||
#[error("failed to load an image: {0}")]
|
#[display("failed to load an image: {_0}")]
|
||||||
ImageError(#[from] image::ImageError),
|
ImageError(image::ImageError),
|
||||||
#[error("unsupported texture format: {0}")]
|
#[display("unsupported texture format: {_0}")]
|
||||||
|
#[from(ignore)]
|
||||||
UnsupportedTextureFormat(String),
|
UnsupportedTextureFormat(String),
|
||||||
#[error("supercompression not supported: {0}")]
|
#[display("supercompression not supported: {_0}")]
|
||||||
|
#[from(ignore)]
|
||||||
SuperCompressionNotSupported(String),
|
SuperCompressionNotSupported(String),
|
||||||
#[error("failed to load an image: {0}")]
|
#[display("failed to load an image: {_0}")]
|
||||||
|
#[from(ignore)]
|
||||||
SuperDecompressionError(String),
|
SuperDecompressionError(String),
|
||||||
#[error("invalid data: {0}")]
|
#[display("invalid data: {_0}")]
|
||||||
|
#[from(ignore)]
|
||||||
InvalidData(String),
|
InvalidData(String),
|
||||||
#[error("transcode error: {0}")]
|
#[display("transcode error: {_0}")]
|
||||||
|
#[from(ignore)]
|
||||||
TranscodeError(String),
|
TranscodeError(String),
|
||||||
#[error("format requires transcoding: {0:?}")]
|
#[display("format requires transcoding: {_0:?}")]
|
||||||
FormatRequiresTranscodingError(TranscodeFormat),
|
FormatRequiresTranscodingError(TranscodeFormat),
|
||||||
/// Only cubemaps with six faces are supported.
|
/// Only cubemaps with six faces are supported.
|
||||||
#[error("only cubemaps with six faces are supported")]
|
#[display("only cubemaps with six faces are supported")]
|
||||||
IncompleteCubemap,
|
IncompleteCubemap,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::{Image, TextureFormatPixelInfo};
|
use crate::{Image, TextureFormatPixelInfo};
|
||||||
use bevy_asset::RenderAssetUsages;
|
use bevy_asset::RenderAssetUsages;
|
||||||
|
use derive_more::derive::{Display, Error};
|
||||||
use image::{DynamicImage, ImageBuffer};
|
use image::{DynamicImage, ImageBuffer};
|
||||||
use thiserror::Error;
|
|
||||||
use wgpu::{Extent3d, TextureDimension, TextureFormat};
|
use wgpu::{Extent3d, TextureDimension, TextureFormat};
|
||||||
|
|
||||||
impl Image {
|
impl Image {
|
||||||
|
@ -204,14 +204,16 @@ impl Image {
|
||||||
|
|
||||||
/// Errors that occur while converting an [`Image`] into a [`DynamicImage`]
|
/// Errors that occur while converting an [`Image`] into a [`DynamicImage`]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Display, Debug)]
|
||||||
pub enum IntoDynamicImageError {
|
pub enum IntoDynamicImageError {
|
||||||
/// Conversion into dynamic image not supported for source format.
|
/// Conversion into dynamic image not supported for source format.
|
||||||
#[error("Conversion into dynamic image not supported for {0:?}.")]
|
#[display("Conversion into dynamic image not supported for {_0:?}.")]
|
||||||
|
#[error(ignore)]
|
||||||
UnsupportedFormat(TextureFormat),
|
UnsupportedFormat(TextureFormat),
|
||||||
|
|
||||||
/// Encountered an unknown error during conversion.
|
/// Encountered an unknown error during conversion.
|
||||||
#[error("Failed to convert into {0:?}.")]
|
#[display("Failed to convert into {_0:?}.")]
|
||||||
|
#[error(ignore)]
|
||||||
UnknownConversionError(TextureFormat),
|
UnknownConversionError(TextureFormat),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue