1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Author: D.S. Ljungmark <spider@skuggor.se>, Modio AB
// SPDX-License-Identifier: AGPL-3.0-or-later

/// Creates an connection to the bus, and spawns a task to poll it's connection.
pub async fn make_connection(session: bool) -> zbus::Result<zbus::Connection> {
    let build = if session {
        zbus::ConnectionBuilder::session()?
    } else {
        zbus::ConnectionBuilder::system()?
    };

    let conn = Box::pin(build.internal_executor(true).build()).await?;
    Ok(conn)
}