Struct Device

Source
pub struct Device {
Show 25 fields pub checksum: Option<Box<str>>, pub created: u64, pub description: Option<Box<str>>, pub device_id: DeviceId, pub flags: DeviceFlags, pub flashes_left: Option<u32>, pub guid: Box<[Box<str>]>, pub icon: Box<[Box<str>]>, pub install_duration: Option<u32>, pub instance_ids: Box<[Box<str>]>, pub modified: Option<u64>, pub name: Box<str>, pub parent_device_id: Option<DeviceId>, pub plugin: Box<str>, pub serial: Option<Box<str>>, pub summary: Option<Box<str>>, pub update_error: Option<Box<str>>, pub update_message: Option<Box<str>>, pub update_state: Option<UpdateState>, pub vendor_id: Box<str>, pub vendor: Box<str>, pub version_bootloader: Option<Box<str>>, pub version_format: Option<VersionFormat>, pub version_lowest: Option<Box<str>>, pub version: Box<str>,
}
Expand description

A device that is potentially-supported by fwupd.

Fields§

§checksum: Option<Box<str>>§created: u64§description: Option<Box<str>>§device_id: DeviceId§flags: DeviceFlags§flashes_left: Option<u32>§guid: Box<[Box<str>]>§icon: Box<[Box<str>]>§install_duration: Option<u32>§instance_ids: Box<[Box<str>]>§modified: Option<u64>§name: Box<str>§parent_device_id: Option<DeviceId>§plugin: Box<str>§serial: Option<Box<str>>§summary: Option<Box<str>>§update_error: Option<Box<str>>§update_message: Option<Box<str>>§update_state: Option<UpdateState>§vendor_id: Box<str>§vendor: Box<str>§version_bootloader: Option<Box<str>>§version_format: Option<VersionFormat>§version_lowest: Option<Box<str>>§version: Box<str>

Implementations§

Source§

impl Device

Source

pub fn has_flag(&self, flags: DeviceFlags) -> bool

Check if the given DeviceFlag is set.

Source

pub fn has_guid(&self, guid: &str) -> bool

Returns true if a GUID match was found.

Source

pub fn is_supported(&self) -> bool

Checks if the device is supported by fwupd.

Source

pub fn is_updateable(&self) -> bool

Determins if the device is updateable or not.

Examples found in repository?
examples/example.rs (line 48)
27fn main_() -> Result<(), Box<dyn Error>> {
28    // Atomic value used to stop the background thread.
29    let cancellable = Arc::new(AtomicBool::new(true));
30
31    // Begin listening to signals in the background
32    listen_in_background(cancellable.clone());
33
34    // Create a new dbus client connection.
35    let fwupd = &Client::new()?;
36
37    println!("Version: {}", fwupd.daemon_version()?);
38    println!("Status: {:?}", fwupd.status()?);
39    println!("Tainted: {}", fwupd.tainted()?);
40    if let Ok(percent) = fwupd.percentage() {
41        println!("Percentage; {}", percent);
42    }
43
44    // Fetch a list of supported devices.
45    for device in fwupd.devices()? {
46        println!("Device: {:#?}", device);
47
48        if device.is_updateable() {
49            if let Ok(upgrades) = fwupd.upgrades(&device) {
50                println!("  upgrades found");
51                for upgrade in upgrades {
52                    println!("{:#?}", upgrade);
53                }
54            } else {
55                println!("  no updates available");
56            }
57
58            if let Ok(downgrades) = fwupd.downgrades(&device) {
59                println!("  downgrades found");
60                for downgrade in downgrades {
61                    println!("{:#?}", downgrade);
62                }
63            }
64
65            if let Ok(releases) = fwupd.releases(&device) {
66                println!("   releases found");
67                for release in releases {
68                    println!("{:#?}", release);
69                }
70            }
71        } else {
72            println!("  device not updateable");
73        }
74    }
75
76    // Fetch a list of remotes, and update them.
77    for remote in fwupd.remotes()? {
78        println!("{:#?}", remote);
79
80        remote.update_metadata(fwupd)?;
81    }
82
83    loop {
84        std::thread::sleep(Duration::from_secs(1));
85    }
86
87    // Stop listening to signals in the background.
88    cancellable.store(true, Ordering::SeqCst);
89
90    Ok(())
91}
Source

pub fn needs_reboot(&self) -> bool

Checks if the device requires a reboot.

Source

pub fn only_offline(&self) -> bool

Check if the device must be updated offline.

Trait Implementations§

Source§

impl AsRef<DeviceId> for Device

Source§

fn as_ref(&self) -> &DeviceId

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Device

Source§

fn clone(&self) -> Device

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

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Device

Source§

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

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

impl Default for Device

Source§

fn default() -> Device

Returns the “default value” for a type. Read more
Source§

impl FromIterator<(String, Variant<Box<dyn RefArg>>)> for Device

Source§

fn from_iter<T>(iter: T) -> Self
where T: IntoIterator<Item = DBusEntry>,

Creates a value from an iterator. Read more

Auto Trait Implementations§

§

impl Freeze for Device

§

impl RefUnwindSafe for Device

§

impl Send for Device

§

impl Sync for Device

§

impl Unpin for Device

§

impl UnwindSafe for Device

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,