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

§

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

Source§

type Output = T

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