Integrate ruma-events
This commit is contained in:
parent
fbf0deacfe
commit
0a788c1273
33 changed files with 65 additions and 235 deletions
|
@ -1,8 +1,2 @@
|
|||
[workspace]
|
||||
members = ["ruma", "ruma-*"]
|
||||
|
||||
# Required until ruma-events becomes part of the workspace
|
||||
[patch.crates-io]
|
||||
ruma-common = { path = "ruma-common" }
|
||||
ruma-identifiers = { path = "ruma-identifiers" }
|
||||
ruma-serde = { path = "ruma-serde" }
|
||||
|
|
|
@ -26,4 +26,4 @@ serde_json = "1.0.53"
|
|||
strum = "0.18.0"
|
||||
|
||||
[dev-dependencies]
|
||||
ruma-events = { git = "https://github.com/ruma/ruma-events", rev = "c1ee72d" }
|
||||
ruma-events = { version = "0.21.3", path = "../ruma-events" }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
pub mod some_endpoint {
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_events::{collections::all, tag::TagEvent, EventJson};
|
||||
use ruma_events::{tag::TagEvent, AnyRoomEvent, EventJson};
|
||||
|
||||
ruma_api! {
|
||||
metadata {
|
||||
|
@ -46,7 +46,7 @@ pub mod some_endpoint {
|
|||
pub event: EventJson<TagEvent>,
|
||||
|
||||
// ... and to allow unknown events when the endpoint deals with event collections.
|
||||
pub list_of_events: Vec<EventJson<all::RoomEvent>>,
|
||||
pub list_of_events: Vec<EventJson<AnyRoomEvent>>,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,8 +12,8 @@ version = "0.1.0"
|
|||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
ruma-api = "0.16.1"
|
||||
ruma-events = { git = "https://github.com/ruma/ruma-events", rev = "c1ee72d" }
|
||||
ruma-api = { version = "0.16.1", path = "../ruma-api" }
|
||||
ruma-events = { version = "0.21.3", path = "../ruma-events" }
|
||||
ruma-identifiers = { version = "0.16.2", path = "../ruma-identifiers" }
|
||||
serde = { version = "1.0.111", features = ["derive"] }
|
||||
serde_json = "1.0.52"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! [PUT /_matrix/app/v1/transactions/{txnId}](https://matrix.org/docs/spec/application_service/r0.1.2#put-matrix-app-v1-transactions-txnid)
|
||||
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_events::{collections::all, EventJson};
|
||||
use ruma_events::{AnyEvent, EventJson};
|
||||
|
||||
ruma_api! {
|
||||
metadata {
|
||||
|
@ -21,7 +21,7 @@ ruma_api! {
|
|||
pub txn_id: String,
|
||||
/// A list of events.
|
||||
#[ruma_api(body)]
|
||||
pub events: Vec<EventJson<all::Event>>,
|
||||
pub events: Vec<EventJson<AnyEvent>>,
|
||||
}
|
||||
|
||||
response {}
|
||||
|
|
|
@ -21,7 +21,7 @@ http = "0.2.1"
|
|||
js_int = { version = "0.1.5", features = ["serde"] }
|
||||
ruma-api = { version = "0.16.1", path = "../ruma-api" }
|
||||
ruma-common = { version = "0.1.3", path = "../ruma-common" }
|
||||
ruma-events = { git = "https://github.com/ruma/ruma-events", rev = "c1ee72d" }
|
||||
ruma-events = { version = "0.21.3", path = "../ruma-events" }
|
||||
ruma-identifiers = { version = "0.16.2", path = "../ruma-identifiers" }
|
||||
ruma-serde = { version = "0.2.2", path = "../ruma-serde" }
|
||||
serde = { version = "1.0.111", features = ["derive"] }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! [GET /_matrix/client/r0/user/{userId}/account_data/{type}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-user-userid-account-data-type)
|
||||
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_events::{collections::only, EventJson};
|
||||
use ruma_events::{AnyBasicEvent, EventJson};
|
||||
use ruma_identifiers::UserId;
|
||||
|
||||
ruma_api! {
|
||||
|
@ -27,7 +27,7 @@ ruma_api! {
|
|||
response {
|
||||
/// Account data content for the given type.
|
||||
#[ruma_api(body)]
|
||||
pub account_data: EventJson<only::Event>,
|
||||
pub account_data: EventJson<AnyBasicEvent>,
|
||||
}
|
||||
|
||||
error: crate::Error
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! [GET /_matrix/client/r0/user/{userId}/rooms/{roomId}/account_data/{type}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-user-userid-rooms-roomid-account-data-type)
|
||||
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_events::{collections::only, EventJson};
|
||||
use ruma_events::{AnyBasicEvent, EventJson};
|
||||
use ruma_identifiers::{RoomId, UserId};
|
||||
|
||||
ruma_api! {
|
||||
|
@ -31,7 +31,7 @@ ruma_api! {
|
|||
response {
|
||||
/// Account data content for the given type.
|
||||
#[ruma_api(body)]
|
||||
pub account_data: EventJson<only::Event>,
|
||||
pub account_data: EventJson<AnyBasicEvent>,
|
||||
}
|
||||
|
||||
error: crate::Error
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use js_int::UInt;
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_events::{collections::all, EventJson};
|
||||
use ruma_events::{AnyRoomEvent, AnyStateEvent, EventJson};
|
||||
use ruma_identifiers::{EventId, RoomId};
|
||||
|
||||
use crate::r0::filter::RoomEventFilter;
|
||||
|
@ -55,20 +55,20 @@ ruma_api! {
|
|||
/// A list of room events that happened just before the requested event,
|
||||
/// in reverse-chronological order.
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub events_before: Vec<EventJson<all::RoomEvent>>,
|
||||
pub events_before: Vec<EventJson<AnyRoomEvent>>,
|
||||
|
||||
/// Details of the requested event.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub event: Option<EventJson<all::RoomEvent>>,
|
||||
pub event: Option<EventJson<AnyRoomEvent>>,
|
||||
|
||||
/// A list of room events that happened just after the requested event,
|
||||
/// in chronological order.
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub events_after: Vec<EventJson<all::RoomEvent>>,
|
||||
pub events_after: Vec<EventJson<AnyRoomEvent>>,
|
||||
|
||||
/// The state of the room at the last event returned.
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub state: Vec<EventJson<all::StateEvent>>,
|
||||
pub state: Vec<EventJson<AnyStateEvent>>,
|
||||
}
|
||||
|
||||
error: crate::Error
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//! Enpoints for sending and receiving messages
|
||||
|
||||
pub mod create_message_event;
|
||||
pub mod get_message_events;
|
||||
//pub mod get_message_events;
|
||||
|
|
|
@ -2,10 +2,7 @@
|
|||
|
||||
use js_int::UInt;
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_events::{
|
||||
collections::all::{RoomEvent, StateEvent},
|
||||
EventJson,
|
||||
};
|
||||
use ruma_events::{AnyRoomEvent, AnyStateEvent, EventJson};
|
||||
use ruma_identifiers::RoomId;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
@ -75,11 +72,11 @@ ruma_api! {
|
|||
|
||||
/// A list of room events.
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub chunk: Vec<EventJson<RoomEvent>>,
|
||||
pub chunk: Vec<EventJson<AnyRoomEvent>>,
|
||||
|
||||
/// A list of state events relevant to showing the `chunk`.
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub state: Vec<EventJson<StateEvent>>,
|
||||
pub state: Vec<EventJson<AnyStateEvent>>,
|
||||
}
|
||||
|
||||
error: crate::Error
|
||||
|
|
|
@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
|
|||
use strum::{Display, EnumString};
|
||||
|
||||
pub mod delete_pushrule;
|
||||
pub mod get_notifications;
|
||||
//pub mod get_notifications;
|
||||
pub mod get_pushers;
|
||||
pub mod get_pushrule;
|
||||
pub mod get_pushrule_actions;
|
||||
|
|
|
@ -4,7 +4,7 @@ use std::time::SystemTime;
|
|||
|
||||
use js_int::UInt;
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_events::{collections::all, EventJson};
|
||||
use ruma_events::{AnyEvent, EventJson};
|
||||
use ruma_identifiers::RoomId;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
@ -59,7 +59,7 @@ pub struct Notification {
|
|||
pub actions: Vec<Action>,
|
||||
|
||||
/// The event that triggered the notification.
|
||||
pub event: EventJson<all::Event>,
|
||||
pub event: EventJson<AnyEvent>,
|
||||
|
||||
/// The profile tag of the rule that matched this event.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Endpoints for room management.
|
||||
|
||||
pub mod create_room;
|
||||
pub mod get_room_event;
|
||||
//pub mod get_room_event;
|
||||
pub mod report_content;
|
||||
pub mod upgrade_room;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! [GET /_matrix/client/r0/rooms/{roomId}/event/{eventId}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-event-eventid)
|
||||
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_events::{collections::all, EventJson};
|
||||
use ruma_events::{AnyRoomEvent, EventJson};
|
||||
use ruma_identifiers::{EventId, RoomId};
|
||||
|
||||
ruma_api! {
|
||||
|
@ -26,7 +26,7 @@ ruma_api! {
|
|||
|
||||
response {
|
||||
/// Arbitrary JSON of the event body. Returns both room and state events.
|
||||
pub event: EventJson<all::RoomEvent>,
|
||||
pub event: EventJson<AnyRoomEvent>,
|
||||
}
|
||||
|
||||
error: crate::Error
|
||||
|
|
|
@ -4,10 +4,7 @@ use std::collections::BTreeMap;
|
|||
|
||||
use js_int::UInt;
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_events::{
|
||||
collections::all::{Event, StateEvent},
|
||||
EventJson,
|
||||
};
|
||||
use ruma_events::{AnyEvent, AnyStateEvent, EventJson};
|
||||
use ruma_identifiers::{EventId, RoomId, UserId};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
@ -122,11 +119,11 @@ pub struct EventContextResult {
|
|||
|
||||
/// Events just after the result.
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub events_after: Vec<EventJson<Event>>,
|
||||
pub events_after: Vec<EventJson<AnyEvent>>,
|
||||
|
||||
/// Events just before the result.
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub events_before: Vec<EventJson<Event>>,
|
||||
pub events_before: Vec<EventJson<AnyEvent>>,
|
||||
|
||||
/// The historic profile information of the users that sent the events returned.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
|
@ -219,7 +216,7 @@ pub struct RoomEventJsons {
|
|||
/// The current state for every room in the results. This is included if the request had the
|
||||
/// `include_state` key set with a value of `true`.
|
||||
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
|
||||
pub state: BTreeMap<RoomId, Vec<EventJson<StateEvent>>>,
|
||||
pub state: BTreeMap<RoomId, Vec<EventJson<AnyStateEvent>>>,
|
||||
|
||||
/// List of words which should be highlighted, useful for stemming which may
|
||||
/// change the query terms.
|
||||
|
@ -256,7 +253,7 @@ pub struct SearchResult {
|
|||
|
||||
/// The event that matched.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub result: Option<EventJson<Event>>,
|
||||
pub result: Option<EventJson<AnyEvent>>,
|
||||
}
|
||||
|
||||
/// A user profile.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! [GET /_matrix/client/r0/rooms/{roomId}/state](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-state)
|
||||
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_events::{collections::all::StateEvent, EventJson};
|
||||
use ruma_events::{AnyStateEvent, EventJson};
|
||||
use ruma_identifiers::RoomId;
|
||||
|
||||
ruma_api! {
|
||||
|
@ -25,7 +25,7 @@ ruma_api! {
|
|||
/// list of events. If the user has left the room then this will be the state of the
|
||||
/// room when they left as a list of events.
|
||||
#[ruma_api(body)]
|
||||
pub room_state: Vec<EventJson<StateEvent>>,
|
||||
pub room_state: Vec<EventJson<AnyStateEvent>>,
|
||||
}
|
||||
|
||||
error: crate::Error
|
||||
|
|
|
@ -5,14 +5,8 @@ use std::{collections::BTreeMap, time::Duration};
|
|||
use js_int::UInt;
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_events::{
|
||||
collections::{
|
||||
all::{RoomEvent, StateEvent},
|
||||
only::Event as NonRoomEvent,
|
||||
},
|
||||
presence::PresenceEvent,
|
||||
stripped::AnyStrippedStateEvent,
|
||||
to_device::AnyToDeviceEvent,
|
||||
EventJson,
|
||||
presence::PresenceEvent, AnyBasicEvent, AnyEphemeralRoomEvent, AnyRoomEvent, AnyStateEvent,
|
||||
AnyStrippedStateEventStub, AnyToDeviceEvent, EventJson,
|
||||
};
|
||||
use ruma_identifiers::{RoomId, UserId};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -249,7 +243,7 @@ pub struct Timeline {
|
|||
pub prev_batch: Option<String>,
|
||||
|
||||
/// A list of events.
|
||||
pub events: Vec<EventJson<RoomEvent>>,
|
||||
pub events: Vec<EventJson<AnyRoomEvent>>,
|
||||
}
|
||||
|
||||
impl Timeline {
|
||||
|
@ -263,7 +257,7 @@ impl Timeline {
|
|||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
pub struct State {
|
||||
/// A list of state events.
|
||||
pub events: Vec<EventJson<StateEvent>>,
|
||||
pub events: Vec<EventJson<AnyStateEvent>>,
|
||||
}
|
||||
|
||||
impl State {
|
||||
|
@ -277,7 +271,7 @@ impl State {
|
|||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
pub struct AccountData {
|
||||
/// A list of events.
|
||||
pub events: Vec<EventJson<NonRoomEvent>>,
|
||||
pub events: Vec<EventJson<AnyBasicEvent>>,
|
||||
}
|
||||
|
||||
impl AccountData {
|
||||
|
@ -291,7 +285,7 @@ impl AccountData {
|
|||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
pub struct Ephemeral {
|
||||
/// A list of events.
|
||||
pub events: Vec<EventJson<NonRoomEvent>>,
|
||||
pub events: Vec<EventJson<AnyEphemeralRoomEvent>>,
|
||||
}
|
||||
|
||||
impl Ephemeral {
|
||||
|
@ -350,7 +344,7 @@ impl InvitedRoom {
|
|||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
pub struct InviteState {
|
||||
/// A list of state events.
|
||||
pub events: Vec<EventJson<AnyStrippedStateEvent>>,
|
||||
pub events: Vec<EventJson<AnyStrippedStateEventStub>>,
|
||||
}
|
||||
|
||||
impl InviteState {
|
||||
|
|
|
@ -21,7 +21,7 @@ proc-macro2 = "1.0.17"
|
|||
proc-macro = true
|
||||
|
||||
[dev-dependencies]
|
||||
ruma-identifiers = "0.16.1"
|
||||
ruma-identifiers = { version = "0.16.1", path = "../ruma-identifiers" }
|
||||
serde_json = "1.0.53"
|
||||
js_int = { version = "0.1.5", features = ["serde"] }
|
||||
serde = { version = "1.0.110", features = ["derive"] }
|
|
@ -14,11 +14,7 @@ pub fn expand_content_enum(input: ContentEnumInput) -> syn::Result<TokenStream>
|
|||
let event_type_str = &input.events;
|
||||
|
||||
let variants = input.events.iter().map(to_camel_case).collect::<Vec<_>>();
|
||||
let content = input
|
||||
.events
|
||||
.iter()
|
||||
.map(to_event_content_path)
|
||||
.collect::<Vec<_>>();
|
||||
let content = input.events.iter().map(to_event_content_path).collect::<Vec<_>>();
|
||||
|
||||
let content_enum = quote! {
|
||||
#( #attrs )*
|
||||
|
@ -116,10 +112,7 @@ pub(crate) fn to_camel_case(name: &LitStr) -> Ident {
|
|||
let name = name.value();
|
||||
|
||||
if &name[..2] != "m." {
|
||||
panic!(
|
||||
"well-known matrix events have to start with `m.` found `{}`",
|
||||
name,
|
||||
)
|
||||
panic!("well-known matrix events have to start with `m.` found `{}`", name,)
|
||||
}
|
||||
|
||||
let s = name[2..]
|
||||
|
@ -170,11 +163,7 @@ impl Parse for ContentEnumInput {
|
|||
.elems
|
||||
.into_iter()
|
||||
.map(|item| {
|
||||
if let Expr::Lit(ExprLit {
|
||||
lit: Lit::Str(lit_str),
|
||||
..
|
||||
}) = item
|
||||
{
|
||||
if let Expr::Lit(ExprLit { lit: Lit::Str(lit_str), .. }) = item {
|
||||
Ok(lit_str)
|
||||
} else {
|
||||
let msg = "values of field `events` are required to be a string literal";
|
||||
|
@ -183,10 +172,6 @@ impl Parse for ContentEnumInput {
|
|||
})
|
||||
.collect::<syn::Result<_>>()?;
|
||||
|
||||
Ok(Self {
|
||||
attrs,
|
||||
name,
|
||||
events,
|
||||
})
|
||||
Ok(Self { attrs, name, events })
|
||||
}
|
||||
}
|
|
@ -27,11 +27,8 @@ impl Parse for EventMeta {
|
|||
pub fn expand_event_content(input: DeriveInput) -> syn::Result<TokenStream> {
|
||||
let ident = &input.ident;
|
||||
|
||||
let event_type_attr = input
|
||||
.attrs
|
||||
.iter()
|
||||
.find(|attr| attr.path.is_ident("ruma_event"))
|
||||
.ok_or_else(|| {
|
||||
let event_type_attr =
|
||||
input.attrs.iter().find(|attr| attr.path.is_ident("ruma_event")).ok_or_else(|| {
|
||||
let msg = "no event type attribute found, \
|
||||
add `#[ruma_event(type = \"any.room.event\")]` \
|
||||
below the event content derive";
|
|
@ -2,11 +2,7 @@
|
|||
//! [ruma-events](https://github.com/ruma/ruma-events) events.
|
||||
//!
|
||||
//! See the documentation for the individual macros for usage details.
|
||||
#![deny(
|
||||
missing_copy_implementations,
|
||||
missing_debug_implementations,
|
||||
missing_docs
|
||||
)]
|
||||
#![deny(missing_copy_implementations, missing_debug_implementations, missing_docs)]
|
||||
|
||||
extern crate proc_macro;
|
||||
|
||||
|
@ -33,70 +29,54 @@ mod event_content;
|
|||
#[proc_macro]
|
||||
pub fn event_content_enum(input: TokenStream) -> TokenStream {
|
||||
let content_enum_input = syn::parse_macro_input!(input as ContentEnumInput);
|
||||
expand_content_enum(content_enum_input)
|
||||
.unwrap_or_else(|err| err.to_compile_error())
|
||||
.into()
|
||||
expand_content_enum(content_enum_input).unwrap_or_else(|err| err.to_compile_error()).into()
|
||||
}
|
||||
|
||||
/// Generates an implementation of `ruma_events::EventContent`.
|
||||
#[proc_macro_derive(EventContent, attributes(ruma_event))]
|
||||
pub fn derive_event_content(input: TokenStream) -> TokenStream {
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
expand_event_content(input)
|
||||
.unwrap_or_else(|err| err.to_compile_error())
|
||||
.into()
|
||||
expand_event_content(input).unwrap_or_else(|err| err.to_compile_error()).into()
|
||||
}
|
||||
|
||||
/// Generates an implementation of `ruma_events::BasicEventContent` and it's super traits.
|
||||
#[proc_macro_derive(BasicEventContent, attributes(ruma_event))]
|
||||
pub fn derive_basic_event_content(input: TokenStream) -> TokenStream {
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
expand_basic_event_content(input)
|
||||
.unwrap_or_else(|err| err.to_compile_error())
|
||||
.into()
|
||||
expand_basic_event_content(input).unwrap_or_else(|err| err.to_compile_error()).into()
|
||||
}
|
||||
|
||||
/// Generates an implementation of `ruma_events::RoomEventContent` and it's super traits.
|
||||
#[proc_macro_derive(RoomEventContent, attributes(ruma_event))]
|
||||
pub fn derive_room_event_content(input: TokenStream) -> TokenStream {
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
expand_room_event_content(input)
|
||||
.unwrap_or_else(|err| err.to_compile_error())
|
||||
.into()
|
||||
expand_room_event_content(input).unwrap_or_else(|err| err.to_compile_error()).into()
|
||||
}
|
||||
|
||||
/// Generates an implementation of `ruma_events::MessageEventContent` and it's super traits.
|
||||
#[proc_macro_derive(MessageEventContent, attributes(ruma_event))]
|
||||
pub fn derive_message_event_content(input: TokenStream) -> TokenStream {
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
expand_message_event_content(input)
|
||||
.unwrap_or_else(|err| err.to_compile_error())
|
||||
.into()
|
||||
expand_message_event_content(input).unwrap_or_else(|err| err.to_compile_error()).into()
|
||||
}
|
||||
|
||||
/// Generates an implementation of `ruma_events::StateEventContent` and it's super traits.
|
||||
#[proc_macro_derive(StateEventContent, attributes(ruma_event))]
|
||||
pub fn derive_state_event_content(input: TokenStream) -> TokenStream {
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
expand_state_event_content(input)
|
||||
.unwrap_or_else(|err| err.to_compile_error())
|
||||
.into()
|
||||
expand_state_event_content(input).unwrap_or_else(|err| err.to_compile_error()).into()
|
||||
}
|
||||
|
||||
/// Generates an implementation of `ruma_events::EphemeralRoomEventContent` and it's super traits.
|
||||
#[proc_macro_derive(EphemeralRoomEventContent, attributes(ruma_event))]
|
||||
pub fn derive_ephemeral_room_event_content(input: TokenStream) -> TokenStream {
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
expand_ephemeral_room_event_content(input)
|
||||
.unwrap_or_else(|err| err.to_compile_error())
|
||||
.into()
|
||||
expand_ephemeral_room_event_content(input).unwrap_or_else(|err| err.to_compile_error()).into()
|
||||
}
|
||||
|
||||
/// Generates implementations needed to serialize and deserialize Matrix events.
|
||||
#[proc_macro_derive(Event, attributes(ruma_event))]
|
||||
pub fn derive_state_event(input: TokenStream) -> TokenStream {
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
expand_event(input)
|
||||
.unwrap_or_else(|err| err.to_compile_error())
|
||||
.into()
|
||||
expand_event(input).unwrap_or_else(|err| err.to_compile_error()).into()
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
image: archlinux
|
||||
packages:
|
||||
- rustup
|
||||
sources:
|
||||
- https://github.com/ruma/ruma-events
|
||||
tasks:
|
||||
- rustup: |
|
||||
# We specify --profile minimal because we'd otherwise download docs
|
||||
rustup toolchain install beta --profile minimal -c rustfmt -c clippy
|
||||
rustup default beta
|
||||
- test: |
|
||||
cd ruma-events
|
||||
|
||||
# We don't want the build to stop on individual failure of independent
|
||||
# tools, so capture tool exit codes and set the task exit code manually
|
||||
set +e
|
||||
|
||||
cargo fmt -- --check
|
||||
fmt_exit=$?
|
||||
|
||||
cargo clippy --all-targets --all-features -- -D warnings
|
||||
clippy_exit=$?
|
||||
|
||||
cargo test --verbose
|
||||
test_exit=$?
|
||||
|
||||
exit $(( $fmt_exit || $clippy_exit || $test_exit ))
|
|
@ -1,16 +0,0 @@
|
|||
image: archlinux
|
||||
packages:
|
||||
- rustup
|
||||
sources:
|
||||
- https://github.com/ruma/ruma-events
|
||||
tasks:
|
||||
- rustup: |
|
||||
# We specify --profile minimal because we'd otherwise download docs
|
||||
rustup toolchain install 1.40.0 --profile minimal
|
||||
rustup default 1.40.0
|
||||
- test: |
|
||||
cd ruma-events
|
||||
|
||||
# Only make sure the code builds with the MSRV. Tests can require later
|
||||
# Rust versions, don't compile or run them.
|
||||
cargo build --verbose
|
|
@ -1,32 +0,0 @@
|
|||
image: archlinux
|
||||
packages:
|
||||
- rustup
|
||||
sources:
|
||||
- https://github.com/ruma/ruma-events
|
||||
tasks:
|
||||
- rustup: |
|
||||
rustup toolchain install nightly --profile minimal
|
||||
rustup default nightly
|
||||
|
||||
# Try installing rustfmt & clippy for nightly, but don't fail the build
|
||||
# if they are not available
|
||||
rustup component add rustfmt || true
|
||||
rustup component add clippy || true
|
||||
- test: |
|
||||
cd ruma-events
|
||||
|
||||
# We don't want the build to stop on individual failure of independent
|
||||
# tools, so capture tool exit codes and set the task exit code manually
|
||||
set +e
|
||||
|
||||
if ( rustup component list | grep -q rustfmt ); then
|
||||
cargo fmt -- --check
|
||||
fi
|
||||
fmt_exit=$?
|
||||
|
||||
if ( rustup component list | grep -q clippy ); then
|
||||
cargo clippy --all-targets --all-features -- -D warnings
|
||||
fi
|
||||
clippy_exit=$?
|
||||
|
||||
exit $(( $fmt_exit || $clippy_exit ))
|
|
@ -1,29 +0,0 @@
|
|||
image: archlinux
|
||||
packages:
|
||||
- rustup
|
||||
sources:
|
||||
- https://github.com/ruma/ruma-events
|
||||
tasks:
|
||||
- rustup: |
|
||||
# We specify --profile minimal because we'd otherwise download docs
|
||||
rustup toolchain install stable --profile minimal -c rustfmt -c clippy
|
||||
rustup default stable
|
||||
- test: |
|
||||
cd ruma-events
|
||||
|
||||
# We don't want the build to stop on individual failure of independent
|
||||
# tools, so capture tool exit codes and set the task exit code manually
|
||||
set +e
|
||||
|
||||
cargo fmt -- --check
|
||||
fmt_exit=$?
|
||||
|
||||
cargo clippy --all-targets --all-features -- -D warnings
|
||||
clippy_exit=$?
|
||||
|
||||
cargo test --verbose
|
||||
test_exit=$?
|
||||
|
||||
exit $(( $fmt_exit || $clippy_exit || $test_exit ))
|
||||
# TODO: Add audit task once cargo-audit binary releases are available.
|
||||
# See https://github.com/RustSec/cargo-audit/issues/66
|
5
ruma-events/.gitignore
vendored
5
ruma-events/.gitignore
vendored
|
@ -1,5 +0,0 @@
|
|||
Cargo.lock
|
||||
target
|
||||
|
||||
# trybuild generates a `wip` folder when creating or updating a test
|
||||
wip
|
|
@ -14,10 +14,10 @@ edition = "2018"
|
|||
|
||||
[dependencies]
|
||||
js_int = { version = "0.1.5", features = ["serde"] }
|
||||
ruma-common = "0.1.3"
|
||||
ruma-events-macros = { path = "ruma-events-macros", version = "=0.21.3" }
|
||||
ruma-identifiers = "0.16.2"
|
||||
ruma-serde = "0.2.2"
|
||||
ruma-common = { version = "0.1.3", path = "../ruma-common" }
|
||||
ruma-events-macros = { version = "=0.21.3", path = "../ruma-events-macros" }
|
||||
ruma-identifiers = { version = "0.16.2", path = "../ruma-identifiers" }
|
||||
ruma-serde = { version = "0.2.2", path = "../ruma-serde" }
|
||||
serde = { version = "1.0.111", features = ["derive"] }
|
||||
serde_json = { version = "1.0.53", features = ["raw_value"] }
|
||||
strum = { version = "0.18.0", features = ["derive"] }
|
||||
|
@ -25,10 +25,5 @@ strum = { version = "0.18.0", features = ["derive"] }
|
|||
[dev-dependencies]
|
||||
maplit = "1.0.2"
|
||||
matches = "0.1.8"
|
||||
ruma-identifiers = { version = "0.16.2", features = ["rand"] }
|
||||
ruma-identifiers = { version = "0.16.2", path = "../ruma-identifiers", features = ["rand"] }
|
||||
trybuild = "1.0.28"
|
||||
|
||||
[workspace]
|
||||
members = [
|
||||
"ruma-events-macros",
|
||||
]
|
||||
|
|
|
@ -19,8 +19,8 @@ version = "0.0.2"
|
|||
js_int = "0.1.5"
|
||||
matches = "0.1.8"
|
||||
ruma-api = { version = "0.16.1", path = "../ruma-api" }
|
||||
ruma-events = { git = "https://github.com/ruma/ruma-events", rev = "c1ee72d" }
|
||||
ruma-events = { version = "0.21.3", path = "../ruma-events" }
|
||||
ruma-identifiers = { version = "0.16.2", path = "../ruma-identifiers" }
|
||||
ruma-serde = "0.2.2"
|
||||
ruma-serde = { version = "0.2.2", path = "../ruma-serde" }
|
||||
serde = { version = "1.0.111", features = ["derive"] }
|
||||
serde_json = "1.0.53"
|
||||
|
|
|
@ -24,7 +24,7 @@ federation-api = ["ruma-api", "ruma-federation-api", "ruma-signatures"]
|
|||
ruma-common = { version = "0.1.3", path = "../ruma-common" }
|
||||
ruma-identifiers = { version = "0.16.2", path = "../ruma-identifiers", features = ["serde"] }
|
||||
|
||||
ruma-events = { git = "https://github.com/ruma/ruma-events", rev = "c1ee72d", optional = true }
|
||||
ruma-events = { version = "0.21.3", path = "../ruma-events", optional = true }
|
||||
ruma-signatures = { version = "0.6.0-dev.1", path = "../ruma-signatures", optional = true }
|
||||
|
||||
ruma-api = { version = "0.16.1", path = "../ruma-api", optional = true }
|
||||
|
|
Loading…
Reference in a new issue