resolvematrix/README.md
theS1LV3R 42fda1eda5
All checks were successful
Checks / Prek / Pre-commit & Formatting (pull_request) Successful in 32s
Checks / Prek / Clippy and Cargo Tests (pull_request) Successful in 1m36s
Checks / Prek / Pre-commit & Formatting (push) Successful in 32s
Checks / Prek / Clippy and Cargo Tests (push) Successful in 1m39s
docs: Update README to include contributing and CoC guidelines
And misc improvements to the lib.rs doc comment.
2026-06-26 20:26:34 +01:00

2.8 KiB

resolvematrix

Dependency status crates.io docs.rs MPL-2.0 license

forgejo.ellis.link Issues Pull Requests GitHub mirror

resolvematrix is a Rust library providing the ability to resolve Matrix server-to-server endpoints from the server name. It conforms to the Server discovery chapter of the Matrix specification.

The library is tested against the https://resolvematrix.dev suite and other live Matrix servers.

This library depends on hickory-resolver, reqwest, serde and (indirectly) tokio.

Usage

cargo add resolvematrix

Example

use resolvematrix::server::{MatrixResolver, MatrixResolverBuilder};

// Create a new resolver
let resolver = Arc::new(MatrixResolver::new()?);
// Or to use custom options:
// MatrixResolverBuilder::new().cache_ttl(Duration::from_secs(10)).build()?

// Resolve a server name
let server_name = "matrix.org";
let resolution = resolver.resolve_server(server_name).await?;
eprintln!("Resolved server: {resolution:?}");

let client = resolver.create_client().unwrap();
let url = format!("{}/_matrix/federation/v1/version", resolution.base_url());
let response = client.get(&url).send().await;

For more examples, see the examples directory.

Contributing

Resolvematrix is part of the Continuwuity project. Please see the Contributing guide before submitting a pull request.

Code of Conduct

Contributors are expected to follow the Continuwuity Community Guidelines.