diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index e37291ef20..222c50248a 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -364,6 +364,8 @@ fn map_buffer( } #[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(deserialize = "'de: 'static")))] pub struct DeviceMismatch { pub(super) res: ResourceErrorIdent, pub(super) res_device: ResourceErrorIdent, @@ -388,6 +390,8 @@ impl std::fmt::Display for DeviceMismatch { impl std::error::Error for DeviceMismatch {} #[derive(Clone, Debug, Error)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(deserialize = "'de: 'static")))] #[non_exhaustive] pub enum DeviceError { #[error("{0} is invalid.")] diff --git a/wgpu-core/src/instance.rs b/wgpu-core/src/instance.rs index 8c580588ff..a16fb0a29f 100644 --- a/wgpu-core/src/instance.rs +++ b/wgpu-core/src/instance.rs @@ -23,6 +23,7 @@ type HalInstance = ::Instance; type HalSurface = ::Surface; #[derive(Clone, Debug, Error)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[error("Limit '{name}' value {requested} is better than allowed {allowed}")] pub struct FailedLimit { name: &'static str, @@ -391,6 +392,8 @@ pub enum GetSurfaceSupportError { } #[derive(Clone, Debug, Error)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(deserialize = "'de: 'static")))] /// Error when requesting a device from the adaptor #[non_exhaustive] pub enum RequestDeviceError { @@ -435,6 +438,7 @@ impl AdapterInputs<'_, M> { pub struct InvalidAdapter; #[derive(Clone, Debug, Error)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[non_exhaustive] pub enum RequestAdapterError { #[error("No suitable adapter found")] diff --git a/wgpu-core/src/resource.rs b/wgpu-core/src/resource.rs index 4e94f1731c..5b11525126 100644 --- a/wgpu-core/src/resource.rs +++ b/wgpu-core/src/resource.rs @@ -76,6 +76,7 @@ impl TrackingData { } #[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ResourceErrorIdent { r#type: &'static str, label: String, @@ -341,6 +342,8 @@ pub struct BufferMapOperation { } #[derive(Clone, Debug, Error)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(deserialize = "'de: 'static")))] #[non_exhaustive] pub enum BufferAccessError { #[error(transparent)] @@ -389,6 +392,8 @@ pub enum BufferAccessError { } #[derive(Clone, Debug, Error)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(deserialize = "'de: 'static")))] #[error("Usage flags {actual:?} of {res} do not contain required usage flags {expected:?}")] pub struct MissingBufferUsageError { pub(crate) res: ResourceErrorIdent, @@ -405,6 +410,8 @@ pub struct MissingTextureUsageError { } #[derive(Clone, Debug, Error)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound(deserialize = "'de: 'static")))] #[error("{0} has been destroyed")] pub struct DestroyedResourceError(pub ResourceErrorIdent);