DeviceClass

Struct DeviceClass 

Source
#[repr(C)]
pub struct DeviceClass {
Show 15 fields pub parent_class: ObjectClass, pub categories: [u64; 1], pub fw_name: *const i8, pub desc: *const i8, pub props: *mut Property, pub user_creatable: bool, pub cannot_destroy_with_object_finalize_yet: bool, pub hotpluggable: bool, pub reset: Option<unsafe extern "C" fn(*mut DeviceState)>, pub realize: Option<unsafe extern "C" fn(*mut DeviceState, *mut *mut Error)>, pub unrealize: Option<unsafe extern "C" fn(*mut DeviceState, *mut *mut Error)>, pub vmsd: *const VMStateDescription, pub init: Option<unsafe extern "C" fn(*mut DeviceState) -> i32>, pub exit: Option<unsafe extern "C" fn(*mut DeviceState) -> i32>, pub bus_type: *const i8,
}
Expand description

DeviceClass: @props: Properties accessing state fields. @realize: Callback function invoked when the #DeviceState:realized property is changed to %true. The default invokes @init if not %NULL. @unrealize: Callback function invoked when the #DeviceState:realized property is changed to %false. @init: Callback function invoked when the #DeviceState::realized property is changed to %true. Deprecated, new types inheriting directly from TYPE_DEVICE should use @realize instead, new leaf types should consult their respective parent type. @hotpluggable: indicates if #DeviceClass is hotpluggable, available as readonly “hotpluggable” property of #DeviceState instance

§Realization

Devices are constructed in two stages,

  1. object instantiation via object_initialize() and
  2. device realization via #DeviceState:realized property. The former may not fail (it might assert or exit), the latter may return error information to the caller and must be re-entrant. Trivial field initializations should go into #TypeInfo.instance_init. Operations depending on @props static properties should go into @realize. After successful realization, setting static properties will fail.

As an interim step, the #DeviceState:realized property can also be set with qdev_init_nofail(). In the future, devices will propagate this state change to their children and along busses they expose. The point in time will be deferred to machine creation, so that values set in @realize will not be introspectable beforehand. Therefore devices must not create children during @realize; they should initialize them via object_initialize() in their own #TypeInfo.instance_init and forward the realization events appropriately.

The @init callback is considered private to a particular bus implementation (immediate abstract child types of TYPE_DEVICE). Derived leaf types set an “init” callback on their parent class instead.

Any type may override the @realize and/or @unrealize callbacks but needs to call the parent type’s implementation if keeping their functionality is desired. Refer to QOM documentation for further discussion and examples.

If a type derived directly from TYPE_DEVICE implements @realize, it does not need to implement @init and therefore does not need to store and call #DeviceClass' default @realize callback. For other types consult the documentation and implementation of the respective parent types.

Fields§

§parent_class: ObjectClass§categories: [u64; 1]§fw_name: *const i8§desc: *const i8§props: *mut Property§user_creatable: bool§cannot_destroy_with_object_finalize_yet: bool§hotpluggable: bool§reset: Option<unsafe extern "C" fn(*mut DeviceState)>§realize: Option<unsafe extern "C" fn(*mut DeviceState, *mut *mut Error)>§unrealize: Option<unsafe extern "C" fn(*mut DeviceState, *mut *mut Error)>§vmsd: *const VMStateDescription§init: Option<unsafe extern "C" fn(*mut DeviceState) -> i32>§exit: Option<unsafe extern "C" fn(*mut DeviceState) -> i32>§bus_type: *const i8

Trait Implementations§

Source§

impl Clone for DeviceClass

Source§

fn clone(&self) -> DeviceClass

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DeviceClass

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Copy for DeviceClass

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.