Macro matrix_sdk_base::ruma::metadata

source ยท
macro_rules! metadata {
    ( $( $field:ident: $rhs:tt ),+ $(,)? ) => { ... };
    ( @field method: $method:ident ) => { ... };
    ( @field authentication: $scheme:ident ) => { ... };
    ( @field history: {
        $( unstable => $unstable_path:literal, )*
        $( $( $version:literal => $rhs:tt, )+ )?
    } ) => { ... };
    ( @field $_field:ident: $rhs:expr ) => { ... };
    ( @history_impl
        [ $($unstable_path:literal),* ]
        $(
            $( $stable_path:literal = $version:literal ),+
            $(,
                deprecated = $deprecated_version:literal
                $(, removed = $removed_version:literal )?
            )?
        )?
    ) => { ... };
    ( @optional_version ) => { ... };
    ( @optional_version $version:literal ) => { ... };
}
Expand description

Convenient constructor for Metadata constants.

Usage:

const _: Metadata = metadata! {
    method: GET, // one of the associated constants of http::Method
    rate_limited: true,
    authentication: AccessToken, // one of the variants of api::AuthScheme

    // history of endpoint paths
    // there must be at least one path but otherwise everything is optional
    history: {
        unstable => "/_matrix/foo/org.bar.msc9000/baz",
        unstable => "/_matrix/foo/org.bar.msc9000/qux",
        1.0 => "/_matrix/media/r0/qux",
        1.1 => "/_matrix/media/v3/qux",
        1.2 => deprecated,
        1.3 => removed,
    }
};