Expand description

Deprecation Notice

Ruma has support for parsing both types of Matrix URIs as of version 0.5.0, thus this crate is now deprecated.

Original Description

A crate for building and parsing Matrix URIs according to both the matrix.to specification and also MSC2312 (matrix://).

Optionally provides conversion to types from ruma_identifiers with the ruma feature

Usage

Building

use matrix_uri::{MatrixUri, MatrixId, MatrixUriAction, IdType};
let uri = MatrixUri::new(
            MatrixId::new(IdType::UserId, String::from("cute:some.url")),
            None,
            None,
            Some(vec![String::from("headpat.services"), String::from("cute.local")]),
            Some(MatrixUriAction::Chat),
        )
        .unwrap();

println!("{} with {}", uri.action().unwrap().to_string(), uri.mxid.to_string()); // `chat with @cute:some.url`
println!("{}", uri.matrix_uri_string()); // `matrix:u/cute%3Asome.url?action=chat&via=headpat.services&via=cute.local`
println!("{}", uri.matrix_to_string()); // `https://matrix.to/#/%40cute%3Asome.url?action=chat&via=headpat.services&via=cute.local`

Parsing

use matrix_uri::MatrixUri;
let uri = "matrix:u/her:example.org?action=chat".parse::<MatrixUri>().unwrap();

println!("{} - {:?}", uri.mxid.to_string(), uri.action().unwrap()); // `@her:example.org - Chat`

Structs

Represents an MXID, has a type and a body

A Matrix URI

Enums

MXID types, documentation can be found here

Actions specifiable by the action query parameter

Error that can happen when generating a MatrixUri from invalid arguments.

Errors encountered while parsing a URI