A Matrix client library written in Rust.

The matrix-sdk aims to be a general purpose client library for writing Matrix clients, bots, and other Matrix related things that use the client-server API to communicate with a Matrix homeserver.

Examples

Connecting and logging in to a homeserver is pretty starightforward:

```rust,norun use std::convert::TryFrom; use matrixsdk::{ Client, SyncSettings, Result, ruma::{UserId, events::{SyncMessageEvent, room::message::MessageEventContent}}, };

[tokio::main]

async fn main() -> Result<()> { let alice = UserId::tryfrom("@alice:example.org")?; let client = Client::newfromuserid(alice.clone()).await?;

// First we need to log in.
client.login(alice.localpart(), "password", None, None).await?;

client
    .register_event_handler(
        |ev: SyncMessageEvent<MessageEventContent>| async move {
            println!("Received a message {:?}", ev);
        },
    )
    .await;

// Syncing is important to synchronize the client state with the server.
// This method will never return.
client.sync(SyncSettings::default()).await;

Ok(())

} ```

More examples can be found in the [examples] directory.

Crate Feature Flags

The following crate feature flags are available:

Enabling logging

Users of the matrix-sdk crate can enable log output by depending on the tracing-subscriber crate and including the following line in their application (e.g. at the start of main):

rust tracing_subscriber::fmt::init();

The log output is controlled via the RUST_LOG environment variable by setting it to one of the error, warn, info, debug or trace levels. The output is printed to stdout.

The RUST_LOG variable also supports a more advanced syntax for filtering log output more precisely, for instance with crate-level granularity. For more information on this, check out the [tracing_subscriber documentation].