Struct fwupd_dbus::Client

source ·
pub struct Client {
    pub client_name: String,
    /* private fields */
}
Expand description

A DBus client for interacting with the fwupd daemon.

Fields§

§client_name: String

Implementations§

source§

impl Client

source

pub fn new() -> Result<Self, Error>

Examples found in repository?
examples/example.rs (line 35)
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
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(())
}

fn listen_in_background(cancellable: Arc<AtomicBool>) {
    thread::spawn(move || {
        if let Ok(fwupd) = Client::new() {
            // Listen for signals received by the daemon.
            let signals = fwupd.listen_signals(cancellable).unwrap();
            for signal in signals {
                match signal {
                    Signal::Changed => {
                        println!("changed");
                    }
                    Signal::DeviceAdded(device) => {
                        println!("device added: {:?}", device);
                    }
                    Signal::DeviceChanged(device) => {
                        println!("device changed: {:?}", device);
                    }
                    Signal::DeviceRemoved(device) => {
                        println!("device added: {:?}", device);
                    }
                    Signal::DeviceRequest(request) => {
                        println!("device request: {:?}", request);
                    }
                    Signal::PropertiesChanged { interface, changed, invalidated } => {
                        println!(
                            "Properties of {} changed:\n changed: {:?}\n invalidated: {:?}",
                            interface, changed, invalidated
                        );
                    }
                }
            }
        }

        eprintln!("STOPPED LISTENING");
    });
}
source

pub fn activate<D: AsRef<DeviceId>>(&self, id: D) -> Result<(), Error>

Activate a firmware update on the device.

source

pub fn clear_results<D: AsRef<DeviceId>>(&self, id: D) -> Result<(), Error>

Clears the results of an offline update.

source

pub fn daemon_version(&self) -> Result<Box<str>, Error>

The version of this daemon.

Examples found in repository?
examples/example.rs (line 37)
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 details<H: IntoRawFd>( &self, handle: H ) -> Result<Vec<HashMap<String, DynVariant>>, Error>

Gets details about a local firmware file.

source

pub fn devices(&self) -> Result<Vec<Device>, Error>

Gets a list of all the devices that are supported.

Examples found in repository?
examples/example.rs (line 45)
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 downgrades<D: AsRef<DeviceId>>( &self, device_id: D ) -> Result<Vec<Release>, Error>

Get a list of all the downgrades possible for a specific device.

Examples found in repository?
examples/example.rs (line 58)
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 fetch_firmware_from_release<C: FnMut(FlashEvent)>( &self, device: &Device, release: &Release, callback: Option<C> ) -> Result<(PathBuf, Option<File>), Error>

Fetches firmware from a remote and caches it for later use.

Firmware will only be fetched if it has not already been cached, or the cached firmware has an invalid checksum.

source

pub fn update_device_with_release<F: FnMut(FlashEvent)>( &self, device: &Device, release: &Release, flags: InstallFlags, callback: Option<F> ) -> Result<(), Error>

Update firmware for a Device with the firmware specified in a Release.

source

pub fn history<H: IntoRawFd>(&self, handle: H) -> Result<Vec<Device>, Error>

Gets a list of all the past firmware updates.

source

pub fn install<D: AsRef<DeviceId>, H: IntoRawFd>( &self, id: D, reason: &str, filename: &Path, handle: Option<H>, flags: InstallFlags ) -> Result<(), Error>

Schedules a firmware to be installed.

source

pub fn listen_signals( &self, cancellable: Arc<AtomicBool> ) -> Result<impl Iterator<Item = Signal> + '_>

Listens for signals from the DBus daemon.

Examples found in repository?
examples/example.rs (line 97)
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
fn listen_in_background(cancellable: Arc<AtomicBool>) {
    thread::spawn(move || {
        if let Ok(fwupd) = Client::new() {
            // Listen for signals received by the daemon.
            let signals = fwupd.listen_signals(cancellable).unwrap();
            for signal in signals {
                match signal {
                    Signal::Changed => {
                        println!("changed");
                    }
                    Signal::DeviceAdded(device) => {
                        println!("device added: {:?}", device);
                    }
                    Signal::DeviceChanged(device) => {
                        println!("device changed: {:?}", device);
                    }
                    Signal::DeviceRemoved(device) => {
                        println!("device added: {:?}", device);
                    }
                    Signal::DeviceRequest(request) => {
                        println!("device request: {:?}", request);
                    }
                    Signal::PropertiesChanged { interface, changed, invalidated } => {
                        println!(
                            "Properties of {} changed:\n changed: {:?}\n invalidated: {:?}",
                            interface, changed, invalidated
                        );
                    }
                }
            }
        }

        eprintln!("STOPPED LISTENING");
    });
}
source

pub fn modify_device<D: AsRef<DeviceId>>( &self, device_id: D, key: &str, value: &str ) -> Result<(), Error>

Modifies a device in some way.

source

pub fn modify_remote<R: AsRef<RemoteId>>( &self, remote_id: R, key: &str, value: &str ) -> Result<(), Error>

Modifies a remote in some way.

source

pub fn percentage(&self) -> Result<u8, Error>

The job percentage completion, or 0 for unknown.

Examples found in repository?
examples/example.rs (line 40)
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 ping(&self) -> Result<(), Error>

source

pub fn releases<D: AsRef<DeviceId>>( &self, device_id: D ) -> Result<Vec<Release>, Error>

Gets a list of all the releases for a specific device.

Examples found in repository?
examples/example.rs (line 65)
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 remote<D: AsRef<RemoteId>>(&self, id: D) -> Result<Remote, Error>

Find the remote with the given ID.

source

pub fn remotes(&self) -> Result<Vec<Remote>, Error>

Gets the list of remotes.

Examples found in repository?
examples/example.rs (line 77)
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 results<D: AsRef<DeviceId>>( &self, id: D ) -> Result<Option<Device>, Error>

Gets the results of an offline update.

source

pub fn set_feature_flags( &self, feature_flags: FeatureFlags ) -> Result<(), Error>

Instructs the daemon about which features this client supports.

source

pub fn status(&self) -> Result<Status, Error>

The daemon status, e.g. Decompressing.

Examples found in repository?
examples/example.rs (line 38)
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 tainted(&self) -> Result<bool, Error>

If the daemon has been tainted with a third party plugin.

Examples found in repository?
examples/example.rs (line 39)
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 unlock<D: AsRef<DeviceId>>(&self, id: D) -> Result<(), Error>

Unlock the device to allow firmware access.

source

pub fn update_metadata<D: IntoRawFd, S: IntoRawFd, R: AsRef<RemoteId>>( &self, remote_id: R, data: D, signature: S ) -> Result<(), Error>

Adds AppStream resource information from a session client.

source

pub fn upgrades<D: AsRef<DeviceId>>( &self, device_id: D ) -> Result<Vec<Release>, Error>

Get a list of all the upgrades possible for a specific device.

Examples found in repository?
examples/example.rs (line 49)
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 verify<D: AsRef<DeviceId>>(&self, id: D) -> Result<(), Error>

Verifies firmware on a device by reading it back and performing a cryptographic hash, typically SHA1.

source

pub fn verify_update<D: AsRef<DeviceId>>(&self, id: D) -> Result<(), Error>

Updates the cryptographic hash stored for a device.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Client

§

impl !Send for Client

§

impl !Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

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.

source§

impl<T> Same<T> for T

§

type Output = T

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