Struct fwupd_dbus::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)
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
fn main_() -> Result<(), Box<dyn Error>> {
    // Atomic value used to stop the background thread.
    let cancellable = Arc::new(AtomicBool::new(true));

    // Begin listening to signals in the background
    listen_in_background(cancellable.clone());

    // Create a new dbus client connection.
    let fwupd = &Client::new()?;

    println!("Version: {}", fwupd.daemon_version()?);
    println!("Status: {:?}", fwupd.status()?);
    println!("Tainted: {}", fwupd.tainted()?);
    if let Ok(percent) = fwupd.percentage() {
        println!("Percentage; {}", percent);
    }

    // Fetch a list of supported devices.
    for device in fwupd.devices()? {
        println!("Device: {:#?}", device);

        if device.is_updateable() {
            if let Ok(upgrades) = fwupd.upgrades(&device) {
                println!("  upgrades found");
                for upgrade in upgrades {
                    println!("{:#?}", upgrade);
                }
            } else {
                println!("  no updates available");
            }

            if let Ok(downgrades) = fwupd.downgrades(&device) {
                println!("  downgrades found");
                for downgrade in downgrades {
                    println!("{:#?}", downgrade);
                }
            }

            if let Ok(releases) = fwupd.releases(&device) {
                println!("   releases found");
                for release in releases {
                    println!("{:#?}", release);
                }
            }
        } else {
            println!("  device not updateable");
        }
    }

    // Fetch a list of remotes, and update them.
    for remote in fwupd.remotes()? {
        println!("{:#?}", remote);

        remote.update_metadata(fwupd)?;
    }

    loop {
        std::thread::sleep(Duration::from_secs(1));
    }

    // Stop listening to signals in the background.
    cancellable.store(true, Ordering::SeqCst);

    Ok(())
}
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 copy 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 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, Global>>)> for Device

source§

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

Creates a value from an iterator. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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.

§

impl<T> NoneValue for Twhere T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

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

§

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