Skip to content

Commit fc87033

Browse files
sagudevcwfitzgerald
authored andcommitted
Make BufferAccessError (de)serializable
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
1 parent d03b7e2 commit fc87033

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

wgpu-core/src/device/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,8 @@ fn map_buffer<A: HalApi>(
364364
}
365365

366366
#[derive(Clone, Debug)]
367+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
368+
#[cfg_attr(feature = "serde", serde(bound(deserialize = "'de: 'static")))]
367369
pub struct DeviceMismatch {
368370
pub(super) res: ResourceErrorIdent,
369371
pub(super) res_device: ResourceErrorIdent,
@@ -388,6 +390,8 @@ impl std::fmt::Display for DeviceMismatch {
388390
impl std::error::Error for DeviceMismatch {}
389391

390392
#[derive(Clone, Debug, Error)]
393+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
394+
#[cfg_attr(feature = "serde", serde(bound(deserialize = "'de: 'static")))]
391395
#[non_exhaustive]
392396
pub enum DeviceError {
393397
#[error("{0} is invalid.")]

wgpu-core/src/resource.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ impl TrackingData {
7676
}
7777

7878
#[derive(Clone, Debug)]
79+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7980
pub struct ResourceErrorIdent {
8081
r#type: &'static str,
8182
label: String,
@@ -341,6 +342,8 @@ pub struct BufferMapOperation {
341342
}
342343

343344
#[derive(Clone, Debug, Error)]
345+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
346+
#[cfg_attr(feature = "serde", serde(bound(deserialize = "'de: 'static")))]
344347
#[non_exhaustive]
345348
pub enum BufferAccessError {
346349
#[error(transparent)]
@@ -389,6 +392,8 @@ pub enum BufferAccessError {
389392
}
390393

391394
#[derive(Clone, Debug, Error)]
395+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
396+
#[cfg_attr(feature = "serde", serde(bound(deserialize = "'de: 'static")))]
392397
#[error("Usage flags {actual:?} of {res} do not contain required usage flags {expected:?}")]
393398
pub struct MissingBufferUsageError {
394399
pub(crate) res: ResourceErrorIdent,
@@ -405,6 +410,8 @@ pub struct MissingTextureUsageError {
405410
}
406411

407412
#[derive(Clone, Debug, Error)]
413+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
414+
#[cfg_attr(feature = "serde", serde(bound(deserialize = "'de: 'static")))]
408415
#[error("{0} has been destroyed")]
409416
pub struct DestroyedResourceError(pub ResourceErrorIdent);
410417

0 commit comments

Comments
 (0)