diff --git a/Cargo.toml b/Cargo.toml index ecc5649..864fb9a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" [dependencies] libc = "0.2" -bitflags = "1.2" +bitflags = "2" drm-fourcc = "2.2" [dependencies.gbm-sys] @@ -33,6 +33,14 @@ version = "0.3" features = ["server_system"] optional = true +[dependencies.serde] +# Minimal serde version that can compile serde-annotated bitflags v2. +# Workaround that allows -Z minimal-versions build to succeed despite bitflags +# crate not declaring minimum versions of its dependencies precisely enough. +version = "1.0.103" +features = ["derive"] +optional = true + [dev-dependencies.drm] version = "0.11.0" @@ -42,6 +50,7 @@ import-wayland = ["wayland-server", "wayland-backend"] import-egl = [] drm-support = ["drm"] use_bindgen = ["gbm-sys/use_bindgen"] +serde = ["dep:serde", "bitflags/serde"] [workspace] members = [ diff --git a/src/buffer_object.rs b/src/buffer_object.rs index 514ee8e..b16c8a6 100644 --- a/src/buffer_object.rs +++ b/src/buffer_object.rs @@ -40,6 +40,8 @@ bitflags! { /// /// Use [`Device::is_format_supported()`] to check if the combination of format /// and use flags are supported + #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(transparent))] + #[derive(Hash, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Debug)] pub struct BufferObjectFlags: u32 { /// Buffer is going to be presented to the screen using an API such as KMS const SCANOUT = ffi::gbm_bo_flags::GBM_BO_USE_SCANOUT as u32;