api: Use metadata macro from ruma_api!

This commit is contained in:
Jonas Platte 2022-10-27 19:25:29 +02:00 committed by Jonas Platte
parent b9ec4db8f0
commit 74dab985aa
2 changed files with 9 additions and 6 deletions

View File

@ -480,7 +480,8 @@ macro_rules! metadata {
};
// Simple literal case: used for description, name, rate_limited
( @field $_field:ident: $rhs:literal ) => { $rhs };
// Also used by ruma_api! while it still exists, for the history field
( @field $_field:ident: $rhs:expr ) => { $rhs };
( @history_impl
[ $($unstable_path:literal),* ]

View File

@ -59,7 +59,6 @@ impl Api {
let maybe_path_error = self.check_paths().err().map(syn::Error::into_compile_error);
let ruma_common = import_ruma_common();
let http = quote! { #ruma_common::exports::http };
let metadata = &self.metadata;
let description = &metadata.description;
@ -83,14 +82,17 @@ impl Api {
#maybe_feature_error
#maybe_path_error
// For some reason inlining the expression causes issues with macro parsing
const _RUMA_API_VERSION_HISTORY: #ruma_common::api::VersionHistory = #history;
#[doc = #metadata_doc]
pub const METADATA: #ruma_common::api::Metadata = #ruma_common::api::Metadata {
pub const METADATA: #ruma_common::api::Metadata = #ruma_common::metadata! {
description: #description,
method: #http::Method::#method,
method: #method,
name: #name,
rate_limited: #rate_limited,
authentication: #ruma_common::api::AuthScheme::#authentication,
history: #history,
authentication: #authentication,
history: _RUMA_API_VERSION_HISTORY,
};
#request