zbus 6.0: What's new in zbus?


Zeeshan Ali Khan

What's zbus?

Pure Rust D-Bus library

5.0 in Oct 2024

Time to break things ๐Ÿ’ฅ

zbus 6.0

One crate to rule them all ๐Ÿ’

zvariant & zbus_names โ†’ zbus

zbus::zvariant still works (deprecated)

GVariant โ†’ zgvariant crate ๐Ÿ‘‹

RIP blocking API ๐Ÿชฆ

// zbus 5
let conn = zbus::blocking::Connection::session()?;
let proxy = MyGreeterProxyBlocking::new(&conn)?;
let reply = proxy.say_hello("Maria")?;

// zbus 6
let reply = zbus::block_on(async {
    let conn = zbus::Connection::session().await?;
    let proxy = MyGreeterProxy::new(&conn).await?;

    proxy.say_hello("Maria").await
})?;

Our own runtime: zruntime ๐Ÿƒ

Runs on the thread calling block_on

Method call roundtrip: 31 ยตs โ†’ 16.9 ยตs ๐Ÿš€

Tokio? Still first-class

Or bring your own runtime ๐ŸŽ’

// `runtime`: any `impl zbus::runtime::traits::Runtime`.
let conn = connection::Builder::session()
    .runtime(runtime)
    .build()
    .await?;

On a diet ๐Ÿฅ—

Default build: 66 โ†’ 38 crates

Opt out of what you don't use:

  • proxy & service
  • object-manager
  • unixexec & ibus
  • tracing

GeoClue2 client: 2113 KiB โ†’ 1840 KiB

Only the features it needs: 1466 KiB ๐ŸŽ‰

Nicer API โœจ

Builders: one ? at the end

// zbus 5
let conn = connection::Builder::session()?
    .name("org.zbus.MyGreeter")?
    .serve_at("/org/zbus/MyGreeter", greeter)?
    .build()
    .await?;

// zbus 6
let conn = connection::Builder::session()
    .name("org.zbus.MyGreeter")
    .serve_at("/org/zbus/MyGreeter", greeter)
    .build()
    .await?;

Easier properties

Thanks, contributors! ๐Ÿ™

@emilio ยท @cachebag ยท @mulkieran ยท @antonok-edm
@robin-simular ยท @olkva ยท @z33ky
@Skyb0rg007 ยท @ChrisJr404 ยท @rrnewton

Upgrade guide ๐Ÿ“–

https://github.com/z-galaxy/zbus/blob/main/book/src/upgrading-to-6.md

That's all folks!

https://github.com/z-galaxy/zbus

vs. zbus 5's async-io backend, from https://github.com/z-galaxy/zbus/pull/1975 (p2p, criterion, one machine). Signals: 13.6 ยตs โ†’ 7.8 ยตs. Setting up & tearing down a connection got slower though: 383 ยตs โ†’ 504 ยตs.

`cargo tree -e normal` on x86_64 Linux, zbus 5.19.0 vs. 6.0, both w/ default features. Gone: async-io, async-executor, async-task, async-lock, async-process, blocking, event-listener, async-broadcast & proc-macro-crate.

zbus's binary-size fixtures, `size` profile (fat LTO, 1 codegen unit, stripped), x86_64 Linux, default runtime. The service: 1896 โ†’ 1669 โ†’ 1444 KiB.