Add failing test to ruma-api for lifetimes in ruma_api! macro

This commit is contained in:
Devin Ragotzy 2020-08-04 19:59:54 -04:00 committed by Jonas Platte
parent 1155edcaed
commit c2342e3ef7

View File

@ -13,24 +13,65 @@ pub struct IncomingThing<T> {
t: T, t: T,
} }
#[derive(Outgoing)] #[allow(unused)]
#[incoming_no_deserialize] #[derive(Copy, Clone, Debug, serde::Deserialize, serde::Serialize)]
pub struct Request<'a, T> { pub struct OtherThing<'t> {
pub abc: &'a str, some: &'t str,
pub thing: Thing<'a, T>, t: &'t [u8],
pub device_id: &'a ::ruma_identifiers::DeviceId,
pub user_id: &'a UserId,
pub bytes: &'a [u8],
pub recursive: &'a [Thing<'a, T>],
pub option: Option<&'a [u8]>,
} }
#[derive(Outgoing)] #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
#[incoming_no_deserialize] pub struct IncomingOtherThing {
pub enum EnumThing<'a, T> { some: String,
Abc(&'a str), t: Vec<u8>,
Stuff(Thing<'a, T>),
Boxy(&'a ::ruma_identifiers::DeviceId),
Other(Option<&'a str>),
StructVar { stuff: &'a str, more: &'a ::ruma_identifiers::ServerName },
} }
use ruma_api::ruma_api;
ruma_api! {
metadata: {
description: "Does something.",
method: GET,
name: "no_fields",
path: "/_matrix/my/endpoint/:thing",
rate_limited: false,
requires_authentication: false,
}
request: {
#[ruma_api(query)]
pub abc: &'a str,
#[ruma_api(path)]
pub thing: &'a str,
#[ruma_api(header = CONTENT_TYPE)]
pub stuff: &'a str,
}
response: {
pub body: &'a str,
pub thing: OtherThing<'a>,
pub stuff: &'a [u8],
}
}
// #[derive(Outgoing)]
// #[incoming_no_deserialize]
// pub struct Request<'a, T> {
// pub abc: &'a str,
// pub thing: Thing<'a, T>,
// pub device_id: &'a ::ruma_identifiers::DeviceId,
// pub user_id: &'a UserId,
// pub bytes: &'a [u8],
// pub recursive: &'a [Thing<'a, T>],
// pub option: Option<&'a [u8]>,
// }
// #[derive(Outgoing)]
// #[incoming_no_deserialize]
// pub enum EnumThing<'a, T> {
// Abc(&'a str),
// Stuff(Thing<'a, T>),
// Boxy(&'a ::ruma_identifiers::DeviceId),
// Other(Option<&'a str>),
// StructVar { stuff: &'a str, more: &'a ::ruma_identifiers::ServerName },
// }