mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-28 21:03:54 -06:00
rust: add IsA bounds to QOM implementation traits
Check that the right bounds are provided to the qom_isa! macro whenever the class is defined to implement a certain class. This removes the need to add IsA<> bounds together with the *Impl trait bounds. Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
646140dfeb
commit
ac5699c5da
2 changed files with 4 additions and 2 deletions
|
@ -37,6 +37,8 @@
|
|||
//! * a trait for virtual method implementations, for example `DeviceImpl`.
|
||||
//! Child classes implement this trait to provide their own behavior for
|
||||
//! virtual methods. The trait's methods take `&self` to access instance data.
|
||||
//! The traits have the appropriate specialization of `IsA<>` as a supertrait,
|
||||
//! for example `IsA<DeviceState>` for `DeviceImpl`.
|
||||
//!
|
||||
//! * an implementation of [`ClassInitImpl`], for example
|
||||
//! `ClassInitImpl<DeviceClass>`. This fills the vtable in the class struct;
|
||||
|
@ -497,7 +499,7 @@ impl<T: ObjectType> ObjectDeref for &mut T {}
|
|||
impl<T: ObjectType> ObjectCastMut for &mut T {}
|
||||
|
||||
/// Trait a type must implement to be registered with QEMU.
|
||||
pub trait ObjectImpl: ObjectType + ClassInitImpl<Self::Class> {
|
||||
pub trait ObjectImpl: ObjectType + ClassInitImpl<Self::Class> + IsA<Object> {
|
||||
/// The parent of the type. This should match the first field of the
|
||||
/// struct that implements `ObjectImpl`, minus the `ParentField<_>` wrapper.
|
||||
type ParentType: ObjectType;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue