loops: Use Void for infinite loops

This commit is contained in:
Dorota Czaplejewicz
2022-12-06 13:01:25 +00:00
parent ea5e36e9fd
commit cf6171a51f
3 changed files with 12 additions and 7 deletions

View File

@ -3,12 +3,13 @@
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
use std::thread;
use zbus::{Connection, ObjectServer, dbus_interface, fdo};
use crate::main;
use crate::state;
use std::thread;
use zbus::{Connection, ObjectServer, dbus_interface, fdo};
use super::Void;
use std::convert::TryInto;
@ -37,7 +38,7 @@ impl Manager {
}
}
fn start(mgr: Manager) -> Result<(), Box<dyn std::error::Error>> {
fn start(mgr: Manager) -> Result<Void, Box<dyn std::error::Error>> {
let connection = Connection::new_session()?;
fdo::DBusProxy::new(&connection)?.request_name(
"sm.puri.SqueekDebug",

View File

@ -8,4 +8,7 @@
pub mod debug;
#[cfg(feature = "zbus_v1_5")]
pub mod screensaver;
pub mod screensaver;
/// The uninhabited type. Cannot be created or returned; means "will never return" as return type. Useful for infinite loops.
enum Void {}

View File

@ -3,10 +3,11 @@
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
use crate::logging;
use std::thread;
use zbus::{Connection, dbus_proxy};
use crate::logging;
use super::Void;
#[derive(Debug)]
@ -45,7 +46,7 @@ pub fn init(destination: Destination) {
});
}
fn start(destination: Destination) -> Result<(), zbus::Error> {
fn start(destination: Destination) -> Result<Void, zbus::Error> {
let conn = Connection::new_session()?;
let manager = ManagerProxy::new(&conn)?;