pub struct DeviceFeatures {
device: u64,
driver: u64,
negotiated: u64,
}Expand description
Modern feature negotiation state: device offer, driver request and the
mask committed when the driver writes FEATURES_OK.
A driver that requests no feature bit at all is treated as a
pre-negotiation driver: FEATURES_OK is accepted with an empty negotiated
mask, so transports that predate feature negotiation keep working. As soon
as the driver requests any bit, Self::negotiate enforces the device
offer and VIRTIO_F_VERSION_1.
Fields§
§device: u64§driver: u64§negotiated: u64Implementations§
Source§impl DeviceFeatures
impl DeviceFeatures
Sourcepub const fn new(device: u64) -> Self
pub const fn new(device: u64) -> Self
Creates a negotiation state with the features offered by the device.
Sourcepub const fn negotiated(&self) -> u64
pub const fn negotiated(&self) -> u64
Features committed at FEATURES_OK (driver & device).
Sourcepub fn write_driver_word(&mut self, select: u32, value: u32)
pub fn write_driver_word(&mut self, select: u32, value: u32)
Updates one 32-bit half of the driver feature request.
Sourcepub fn read_driver_word(&self, select: u32) -> u32
pub fn read_driver_word(&self, select: u32) -> u32
Reads one 32-bit half of the driver feature request.
Sourcepub fn read_device_word(&self, select: u32) -> u32
pub fn read_device_word(&self, select: u32) -> u32
Reads one 32-bit half of the device feature offer.
Sourcepub fn negotiate(&mut self) -> Result<u64, FeatureError>
pub fn negotiate(&mut self) -> Result<u64, FeatureError>
Validates the driver request and commits driver & device.
Sourcepub fn clear_negotiated(&mut self)
pub fn clear_negotiated(&mut self)
Drops the committed mask (driver cleared FEATURES_OK).
Sourcepub const fn version_1(&self) -> bool
pub const fn version_1(&self) -> bool
True if VIRTIO_F_VERSION_1 was negotiated.
Trait Implementations§
Source§impl Clone for DeviceFeatures
impl Clone for DeviceFeatures
impl Copy for DeviceFeatures
Source§impl Debug for DeviceFeatures
impl Debug for DeviceFeatures
Source§impl Default for DeviceFeatures
impl Default for DeviceFeatures
impl Eq for DeviceFeatures
Source§impl PartialEq for DeviceFeatures
impl PartialEq for DeviceFeatures
impl StructuralPartialEq for DeviceFeatures
Auto Trait Implementations§
impl Forget for DeviceFeatures
impl Freeze for DeviceFeatures
impl Move for DeviceFeatures
impl RefUnwindSafe for DeviceFeatures
impl Send for DeviceFeatures
impl Sync for DeviceFeatures
impl Unpin for DeviceFeatures
impl UnsafeUnpin for DeviceFeatures
impl UnwindSafe for DeviceFeatures
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more