the new core and its future

Benjamin Kampmann
2022-08-27, Matrix Summit Berlin

rust SDK

matrix logo white Created with Sketch.

It'se me, Ben

Rust Developer @ New Vector/Element

Lead-Dev for matrix-rust-sdk

Co-Founder & Tech-Lead effektio


Freelance Dev since 2011

Rust Dev since 2015 (before Python, JS, etc)

prev. Core Dev @ Parity on Substrate (blockchain dev framework); App-SDK Dev @ MaidSafe

Co-Host RustFest 2016 & 2017

more about me on

What the rust?

obligatory rust-intro slides



as fast & sometimes faster than c/c++; no garbage collector


typed; without segfaults; checked at compile time


LLVM backend


Lovely People

Great Tooling

Massive Docs

What rust looks like

use rand::Rng;

struct CustomType {
    inner: String

impl CustomType {
    pub fn new(inner: String) -> Self {
        CustomType { inner }

fn main() {
    let mut rng = rand::thread_rng();
    let num = rng.gen::<u8>();
    let conv = match num {
        0 => Some(CustomType::new("Zero".to_owned())),
        5 => Some(CustomType::new("Zero".to_owned())),
        _ => None,

    if let Some(t) = conv {
        println!("{}", t.inner);
    } else {
        println!("{}", num)

But why are we talking about this?

there are issues...


Spec and the ecosystem are thriving


  • The main crypto library is C
  • which is not very portable and hard to maintain for users
  • which means a lot of clients don't ever bother implementing e2ee


  • A lot has changed since the first clients have been developed
  • a lot has been learned, but not necessarily been translated into cross-plattform code
  • Old code-base also means it is harder to experiment with new features

Which overall means

Matrix Clients are all over the place; developing one is hard and most lack a core aspect end-to-end-encryption because of a lack of well supported libraries. This slows down development of matrix as a whole.



The Matrix Rust SDK


Matrix Development Toolkit with crypto built-in

Key Features

  • Sync state, rooms, events, devices & ephemeral events
  • handle end-2-end-encryption transparently for you
  • verify device(s), exchange keys
  • fetch attachments, avatars
    and if enabled, resize images for you
  • compute and manage common state
    e.g. rooms member list, display_name
  • pluggable persistent storage layers for state
    with sled on native, indexeddb for wasm/web
  • various bindings
    with uniffi for Swift; crypto for NodeJS, Python

Server / Bot

Web (wasm)


// from `examples/getting_started/src/`
async fn on_room_message(event: OriginalSyncRoomMessageEvent, room: Room) {
    // First, we need to unpack the message: We only want messages from rooms we are
    // still in and that are regular text messages - ignoring everything else.
    if let Room::Joined(room) = room {
        let msg_body = match event.content.msgtype {
            MessageType::Text(TextMessageEventContent { body, .. }) => body,
            _ => return,
        // here comes the actual "logic": when the bot see's a `!party` in the message,
        // it responds
        if msg_body.contains("!party") {
            let content = RoomMessageEventContent::text_plain("🎉🎊🥳 let's PARTY!! 🥳🎊🎉");
            // send our message to the room we found the "!party" command in
            // the last parameter is an optional transaction id which we don't
            // care about.
            room.send(content, None).await.unwrap();
            println!("message sent");
// ...

Join the matrix SDK workshop here @2pm

  • More fast: Sliding Sync support, #728
  • More state machine: New Timeline API, #940
  • More platforms: Kotlin, CryptoJS for the browser (wasm)
  • More secret: next-gen megolm

rust SDK

matrix logo white Created with Sketch.


already in the works:

and beyond

  • Extended Timeline State machines
  • Encrypted Appservices
  • Async over FFI
  • More storage backends

Want more vision and future? Join my closing talk today @ 5pm in mainhall



rust SDK:

matrix logo white Created with Sketch.

Matrix Rust SDK

By Benjamin Kampmann

Matrix Rust SDK

  • 360