Skip to content

Commit fd5469a

Browse files
committed
feat(features): seal FeatureBits
1 parent 26f03e0 commit fd5469a

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/features.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
//! Feature Bits
22
33
use crate::le128;
4+
use crate::sealed::Sealed;
45

56
/// Feature Bits
67
#[doc(alias = "VIRTIO_F")]
78
pub trait FeatureBits:
8-
bitflags::Flags<Bits = le128> + From<F> + Into<F> + AsRef<F> + AsMut<F>
9+
bitflags::Flags<Bits = le128> + From<F> + Into<F> + AsRef<F> + AsMut<F> + Sealed
910
{
1011
/// Returns the feature that this feature requires.
1112
///
@@ -238,6 +239,8 @@ impl AsMut<F> for F {
238239

239240
impl FeatureBits for F {}
240241

242+
impl Sealed for F {}
243+
241244
macro_rules! feature_bits {
242245
(
243246
$(#[$outer:meta])*
@@ -332,6 +335,8 @@ macro_rules! feature_bits {
332335
}
333336
}
334337

338+
impl $crate::sealed::Sealed for $BitFlags {}
339+
335340
feature_bits! {
336341
$($t)*
337342
}

src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ pub mod pvirtq;
109109
pub mod virtq;
110110
pub mod vsock;
111111

112+
mod sealed {
113+
pub trait Sealed {}
114+
}
115+
112116
pub use endian_num::{be128, be16, be32, be64, le128, le16, le32, le64, Be, Le};
113117
use num_enum::{FromPrimitive, IntoPrimitive, TryFromPrimitive};
114118

0 commit comments

Comments
 (0)