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
impl Client
sourcepub fn new() -> Result<Self, Error>
pub fn new() -> Result<Self, Error>
Examples found in repository?
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");
});
}
sourcepub fn activate<D: AsRef<DeviceId>>(&self, id: D) -> Result<(), Error>
pub fn activate<D: AsRef<DeviceId>>(&self, id: D) -> Result<(), Error>
Activate a firmware update on the device.
sourcepub fn clear_results<D: AsRef<DeviceId>>(&self, id: D) -> Result<(), Error>
pub fn clear_results<D: AsRef<DeviceId>>(&self, id: D) -> Result<(), Error>
Clears the results of an offline update.
sourcepub fn daemon_version(&self) -> Result<Box<str>, Error>
pub fn daemon_version(&self) -> Result<Box<str>, Error>
The version of this daemon.
Examples found in repository?
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(())
}
sourcepub fn details<H: IntoRawFd>(
&self,
handle: H
) -> Result<Vec<HashMap<String, DynVariant>>, Error>
pub fn details<H: IntoRawFd>( &self, handle: H ) -> Result<Vec<HashMap<String, DynVariant>>, Error>
Gets details about a local firmware file.
sourcepub fn devices(&self) -> Result<Vec<Device>, Error>
pub fn devices(&self) -> Result<Vec<Device>, Error>
Gets a list of all the devices that are supported.
Examples found in repository?
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(())
}
sourcepub fn downgrades<D: AsRef<DeviceId>>(
&self,
device_id: D
) -> Result<Vec<Release>, Error>
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?
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(())
}
sourcepub fn fetch_firmware_from_release<C: FnMut(FlashEvent)>(
&self,
device: &Device,
release: &Release,
callback: Option<C>
) -> Result<(PathBuf, Option<File>), Error>
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.
sourcepub fn update_device_with_release<F: FnMut(FlashEvent)>(
&self,
device: &Device,
release: &Release,
flags: InstallFlags,
callback: Option<F>
) -> Result<(), Error>
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
.
sourcepub fn history<H: IntoRawFd>(&self, handle: H) -> Result<Vec<Device>, Error>
pub fn history<H: IntoRawFd>(&self, handle: H) -> Result<Vec<Device>, Error>
Gets a list of all the past firmware updates.
sourcepub fn install<D: AsRef<DeviceId>, H: IntoRawFd>(
&self,
id: D,
reason: &str,
filename: &Path,
handle: Option<H>,
flags: InstallFlags
) -> Result<(), Error>
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.
sourcepub fn listen_signals(
&self,
cancellable: Arc<AtomicBool>
) -> Result<impl Iterator<Item = Signal> + '_>
pub fn listen_signals( &self, cancellable: Arc<AtomicBool> ) -> Result<impl Iterator<Item = Signal> + '_>
Listens for signals from the DBus daemon.
Examples found in repository?
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");
});
}
sourcepub fn modify_device<D: AsRef<DeviceId>>(
&self,
device_id: D,
key: &str,
value: &str
) -> Result<(), Error>
pub fn modify_device<D: AsRef<DeviceId>>( &self, device_id: D, key: &str, value: &str ) -> Result<(), Error>
Modifies a device in some way.
sourcepub fn modify_remote<R: AsRef<RemoteId>>(
&self,
remote_id: R,
key: &str,
value: &str
) -> Result<(), Error>
pub fn modify_remote<R: AsRef<RemoteId>>( &self, remote_id: R, key: &str, value: &str ) -> Result<(), Error>
Modifies a remote in some way.
sourcepub fn percentage(&self) -> Result<u8, Error>
pub fn percentage(&self) -> Result<u8, Error>
The job percentage completion, or 0 for unknown.
Examples found in repository?
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(())
}
pub fn ping(&self) -> Result<(), Error>
sourcepub fn releases<D: AsRef<DeviceId>>(
&self,
device_id: D
) -> Result<Vec<Release>, Error>
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?
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(())
}
sourcepub fn remote<D: AsRef<RemoteId>>(&self, id: D) -> Result<Remote, Error>
pub fn remote<D: AsRef<RemoteId>>(&self, id: D) -> Result<Remote, Error>
Find the remote with the given ID.
sourcepub fn remotes(&self) -> Result<Vec<Remote>, Error>
pub fn remotes(&self) -> Result<Vec<Remote>, Error>
Gets the list of remotes.
Examples found in repository?
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(())
}
sourcepub fn results<D: AsRef<DeviceId>>(
&self,
id: D
) -> Result<Option<Device>, Error>
pub fn results<D: AsRef<DeviceId>>( &self, id: D ) -> Result<Option<Device>, Error>
Gets the results of an offline update.
sourcepub fn set_feature_flags(
&self,
feature_flags: FeatureFlags
) -> Result<(), Error>
pub fn set_feature_flags( &self, feature_flags: FeatureFlags ) -> Result<(), Error>
Instructs the daemon about which features this client supports.
sourcepub fn status(&self) -> Result<Status, Error>
pub fn status(&self) -> Result<Status, Error>
The daemon status, e.g. Decompressing
.
Examples found in repository?
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(())
}
sourcepub fn tainted(&self) -> Result<bool, Error>
pub fn tainted(&self) -> Result<bool, Error>
If the daemon has been tainted with a third party plugin.
Examples found in repository?
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(())
}
sourcepub fn unlock<D: AsRef<DeviceId>>(&self, id: D) -> Result<(), Error>
pub fn unlock<D: AsRef<DeviceId>>(&self, id: D) -> Result<(), Error>
Unlock the device to allow firmware access.
sourcepub fn update_metadata<D: IntoRawFd, S: IntoRawFd, R: AsRef<RemoteId>>(
&self,
remote_id: R,
data: D,
signature: S
) -> Result<(), Error>
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.
sourcepub fn upgrades<D: AsRef<DeviceId>>(
&self,
device_id: D
) -> Result<Vec<Release>, Error>
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?
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(())
}