From 4ccf79cb67c1431d76d043757e4310edf1194026 Mon Sep 17 00:00:00 2001 From: Jonathan de Jong Date: Sat, 12 Feb 2022 20:29:42 +0100 Subject: [PATCH] api: Add _path suffix to new path metadata keywords --- crates/ruma-api-macros/src/api/metadata.rs | 48 +++++++++---------- .../ruma-api/tests/ui/01-api-sanity-check.rs | 6 +-- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/crates/ruma-api-macros/src/api/metadata.rs b/crates/ruma-api-macros/src/api/metadata.rs index 0b86cfa8..8fb932f9 100644 --- a/crates/ruma-api-macros/src/api/metadata.rs +++ b/crates/ruma-api-macros/src/api/metadata.rs @@ -15,9 +15,9 @@ mod kw { syn::custom_keyword!(method); syn::custom_keyword!(name); syn::custom_keyword!(path); - syn::custom_keyword!(unstable); - syn::custom_keyword!(r0); - syn::custom_keyword!(stable); + syn::custom_keyword!(unstable_path); + syn::custom_keyword!(r0_path); + syn::custom_keyword!(stable_path); syn::custom_keyword!(rate_limited); syn::custom_keyword!(authentication); syn::custom_keyword!(added); @@ -117,9 +117,9 @@ impl Parse for Metadata { FieldValue::Method(m) => set_field(&mut method, m)?, FieldValue::Name(n) => set_field(&mut name, n)?, FieldValue::Path(p) => set_field(&mut path, p)?, - FieldValue::Unstable(p) => set_field(&mut unstable_path, p)?, - FieldValue::R0(p) => set_field(&mut r0_path, p)?, - FieldValue::Stable(p) => set_field(&mut stable_path, p)?, + FieldValue::UnstablePath(p) => set_field(&mut unstable_path, p)?, + FieldValue::R0Path(p) => set_field(&mut r0_path, p)?, + FieldValue::StablePath(p) => set_field(&mut stable_path, p)?, FieldValue::RateLimited(value, attrs) => { rate_limited.push(MetadataField { attrs, value }); } @@ -205,9 +205,9 @@ enum Field { Method, Name, Path, - Unstable, - R0, - Stable, + UnstablePath, + R0Path, + StablePath, RateLimited, Authentication, Added, @@ -231,15 +231,15 @@ impl Parse for Field { } else if lookahead.peek(kw::path) { let _: kw::path = input.parse()?; Ok(Self::Path) - } else if lookahead.peek(kw::unstable) { - let _: kw::unstable = input.parse()?; - Ok(Self::Unstable) - } else if lookahead.peek(kw::r0) { - let _: kw::r0 = input.parse()?; - Ok(Self::R0) - } else if lookahead.peek(kw::stable) { - let _: kw::stable = input.parse()?; - Ok(Self::Stable) + } else if lookahead.peek(kw::unstable_path) { + let _: kw::unstable_path = input.parse()?; + Ok(Self::UnstablePath) + } else if lookahead.peek(kw::r0_path) { + let _: kw::r0_path = input.parse()?; + Ok(Self::R0Path) + } else if lookahead.peek(kw::stable_path) { + let _: kw::stable_path = input.parse()?; + Ok(Self::StablePath) } else if lookahead.peek(kw::rate_limited) { let _: kw::rate_limited = input.parse()?; Ok(Self::RateLimited) @@ -266,9 +266,9 @@ enum FieldValue { Method(Ident), Name(LitStr), Path(EndpointPath), - Unstable(EndpointPath), - R0(EndpointPath), - Stable(EndpointPath), + UnstablePath(EndpointPath), + R0Path(EndpointPath), + StablePath(EndpointPath), RateLimited(LitBool, Vec), Authentication(AuthScheme, Vec), Added(MatrixVersionLiteral), @@ -295,9 +295,9 @@ impl Parse for FieldValue { Field::Method => Self::Method(input.parse()?), Field::Name => Self::Name(input.parse()?), Field::Path => Self::Path(input.parse()?), - Field::Unstable => Self::Unstable(input.parse()?), - Field::R0 => Self::R0(input.parse()?), - Field::Stable => Self::Stable(input.parse()?), + Field::UnstablePath => Self::UnstablePath(input.parse()?), + Field::R0Path => Self::R0Path(input.parse()?), + Field::StablePath => Self::StablePath(input.parse()?), Field::RateLimited => Self::RateLimited(input.parse()?, attrs), Field::Authentication => Self::Authentication(input.parse()?, attrs), Field::Added => Self::Added(input.parse()?), diff --git a/crates/ruma-api/tests/ui/01-api-sanity-check.rs b/crates/ruma-api/tests/ui/01-api-sanity-check.rs index 88e46fb0..625949bb 100644 --- a/crates/ruma-api/tests/ui/01-api-sanity-check.rs +++ b/crates/ruma-api/tests/ui/01-api-sanity-check.rs @@ -8,9 +8,9 @@ ruma_api! { method: POST, // An `http::Method` constant. No imports required. name: "some_endpoint", path: "/_matrix/some/endpoint/:baz", - unstable: "/_matrix/some/msc1234/endpoint/:baz", - r0: "/_matrix/some/r0/endpoint/:baz", - stable: "/_matrix/some/v1/endpoint/:baz", + unstable_path: "/_matrix/some/msc1234/endpoint/:baz", + r0_path: "/_matrix/some/r0/endpoint/:baz", + stable_path: "/_matrix/some/v1/endpoint/:baz", rate_limited: false, authentication: None, added: 1.0,