Uncomment all event enum variants, convert remaining ruma_event!
usages
This commit is contained in:
parent
aea827a199
commit
92a2dfa2e8
@ -1,127 +0,0 @@
|
|||||||
//! Details of generating code for the `ruma_event` procedural macro.
|
|
||||||
|
|
||||||
#![allow(dead_code)]
|
|
||||||
|
|
||||||
use proc_macro2::{Span, TokenStream};
|
|
||||||
use quote::{format_ident, quote, ToTokens};
|
|
||||||
use syn::{
|
|
||||||
parse::{self, Parse, ParseStream},
|
|
||||||
parse_quote,
|
|
||||||
punctuated::Punctuated,
|
|
||||||
Attribute, Field, Ident, LitStr, Token,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::parse::{Content, EventKind, RumaEventInput};
|
|
||||||
|
|
||||||
/// The result of processing the `ruma_event` macro, ready for output back to source code.
|
|
||||||
pub struct RumaEvent {
|
|
||||||
/// Outer attributes on the field, such as a docstring.
|
|
||||||
attrs: Vec<Attribute>,
|
|
||||||
|
|
||||||
/// Information for generating the type used for the event's `content` field.
|
|
||||||
content: Content,
|
|
||||||
|
|
||||||
/// The name of the type of the event's `content` field.
|
|
||||||
content_name: Ident,
|
|
||||||
|
|
||||||
/// The variant of `ruma_events::EventType` for this event, determined by the `event_type`
|
|
||||||
/// field.
|
|
||||||
event_type: LitStr,
|
|
||||||
|
|
||||||
/// Struct fields of the event.
|
|
||||||
fields: Vec<Field>,
|
|
||||||
|
|
||||||
/// The kind of event.
|
|
||||||
kind: EventKind,
|
|
||||||
|
|
||||||
/// The name of the event.
|
|
||||||
name: Ident,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<RumaEventInput> for RumaEvent {
|
|
||||||
fn from(input: RumaEventInput) -> Self {
|
|
||||||
let kind = input.kind;
|
|
||||||
let name = input.name;
|
|
||||||
let content_name = format_ident!("{}Content", name, span = Span::call_site());
|
|
||||||
let event_type = input.event_type;
|
|
||||||
|
|
||||||
let mut fields =
|
|
||||||
populate_event_fields(content_name.clone(), input.fields.unwrap_or_else(Vec::new));
|
|
||||||
|
|
||||||
fields.sort_unstable_by_key(|field| field.ident.clone().unwrap());
|
|
||||||
|
|
||||||
Self {
|
|
||||||
attrs: input.attrs,
|
|
||||||
content: input.content,
|
|
||||||
content_name,
|
|
||||||
event_type,
|
|
||||||
fields,
|
|
||||||
kind,
|
|
||||||
name,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ToTokens for RumaEvent {
|
|
||||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
|
||||||
// let attrs = &self.attrs;
|
|
||||||
let content_name = &self.content_name;
|
|
||||||
// let event_fields = &self.fields;
|
|
||||||
// let event_type = &self.event_type;
|
|
||||||
|
|
||||||
let name = &self.name;
|
|
||||||
let content_docstring = format!("The payload for `{}`.", name);
|
|
||||||
|
|
||||||
let content = match &self.content {
|
|
||||||
Content::Struct(fields) => {
|
|
||||||
quote! {
|
|
||||||
#[doc = #content_docstring]
|
|
||||||
#[derive(Clone, Debug, ::serde::Serialize, ::serde::Deserialize)]
|
|
||||||
pub struct #content_name {
|
|
||||||
#(#fields),*
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Content::Typedef(typedef) => {
|
|
||||||
let content_attrs = &typedef.attrs;
|
|
||||||
let path = &typedef.path;
|
|
||||||
|
|
||||||
quote! {
|
|
||||||
#(#content_attrs)*
|
|
||||||
pub type #content_name = #path;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
content.to_tokens(tokens);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Fills in the event's struct definition with fields common to all basic events.
|
|
||||||
fn populate_event_fields(content_name: Ident, mut fields: Vec<Field>) -> Vec<Field> {
|
|
||||||
let punctuated_fields: Punctuated<ParsableNamedField, Token![,]> = parse_quote! {
|
|
||||||
/// The event's content.
|
|
||||||
pub content: #content_name,
|
|
||||||
};
|
|
||||||
|
|
||||||
fields.extend(punctuated_fields.into_iter().map(|p| p.field));
|
|
||||||
|
|
||||||
fields
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A wrapper around `syn::Field` that makes it possible to parse `Punctuated<Field, Token![,]>`
|
|
||||||
/// from a `TokenStream`.
|
|
||||||
///
|
|
||||||
/// See https://github.com/dtolnay/syn/issues/651 for more context.
|
|
||||||
struct ParsableNamedField {
|
|
||||||
/// The wrapped `Field`.
|
|
||||||
pub field: Field,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Parse for ParsableNamedField {
|
|
||||||
fn parse(input: ParseStream<'_>) -> parse::Result<Self> {
|
|
||||||
let field = Field::parse_named(input)?;
|
|
||||||
|
|
||||||
Ok(Self { field })
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,7 +11,6 @@
|
|||||||
extern crate proc_macro;
|
extern crate proc_macro;
|
||||||
|
|
||||||
use proc_macro::TokenStream;
|
use proc_macro::TokenStream;
|
||||||
use quote::ToTokens;
|
|
||||||
use syn::{parse_macro_input, DeriveInput};
|
use syn::{parse_macro_input, DeriveInput};
|
||||||
|
|
||||||
use self::{
|
use self::{
|
||||||
@ -22,109 +21,12 @@ use self::{
|
|||||||
expand_message_event_content, expand_room_event_content, expand_state_event_content,
|
expand_message_event_content, expand_room_event_content, expand_state_event_content,
|
||||||
},
|
},
|
||||||
event_enum::{expand_event_enum, EventEnumInput},
|
event_enum::{expand_event_enum, EventEnumInput},
|
||||||
gen::RumaEvent,
|
|
||||||
parse::RumaEventInput,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mod content_enum;
|
mod content_enum;
|
||||||
mod event;
|
mod event;
|
||||||
mod event_content;
|
mod event_content;
|
||||||
mod event_enum;
|
mod event_enum;
|
||||||
mod gen;
|
|
||||||
mod parse;
|
|
||||||
|
|
||||||
// A note about the `example` modules that appears in doctests:
|
|
||||||
//
|
|
||||||
// This is necessary because otherwise the expanded code appears in function context, which makes
|
|
||||||
// the compiler interpret the output of the macro as a statement, and proc macros currently aren't
|
|
||||||
// allowed to expand to statements, resulting in a compiler error.
|
|
||||||
|
|
||||||
/// Generates a Rust type for a Matrix event.
|
|
||||||
///
|
|
||||||
/// # Examples
|
|
||||||
///
|
|
||||||
/// The most common form of event is a struct with all the standard fields for an event of its
|
|
||||||
/// kind and a struct for its `content` field:
|
|
||||||
///
|
|
||||||
/// ```ignore
|
|
||||||
/// # pub mod example {
|
|
||||||
/// # use ruma_events_macros::ruma_event;
|
|
||||||
/// ruma_event! {
|
|
||||||
/// /// Informs the room about what room aliases it has been given.
|
|
||||||
/// AliasesEvent {
|
|
||||||
/// kind: StateEvent,
|
|
||||||
/// event_type: RoomAliases,
|
|
||||||
/// content: {
|
|
||||||
/// /// A list of room aliases.
|
|
||||||
/// pub aliases: Vec<ruma_identifiers::RoomAliasId>,
|
|
||||||
/// }
|
|
||||||
/// }
|
|
||||||
/// }
|
|
||||||
/// # }
|
|
||||||
/// ```
|
|
||||||
///
|
|
||||||
/// Occasionally an event will have non-standard fields at its top level (outside the `content`
|
|
||||||
/// field). These extra fields are declared in block labeled with `fields`:
|
|
||||||
///
|
|
||||||
/// ```ignore
|
|
||||||
/// # pub mod example {
|
|
||||||
/// # use ruma_events_macros::ruma_event;
|
|
||||||
/// ruma_event! {
|
|
||||||
/// /// A redaction of an event.
|
|
||||||
/// RedactionEvent {
|
|
||||||
/// kind: RoomEvent,
|
|
||||||
/// event_type: RoomRedaction,
|
|
||||||
/// fields: {
|
|
||||||
/// /// The ID of the event that was redacted.
|
|
||||||
/// pub redacts: ruma_identifiers::EventId
|
|
||||||
/// },
|
|
||||||
/// content: {
|
|
||||||
/// /// The reason for the redaction, if any.
|
|
||||||
/// pub reason: Option<String>,
|
|
||||||
/// },
|
|
||||||
/// }
|
|
||||||
/// }
|
|
||||||
/// # }
|
|
||||||
/// ```
|
|
||||||
///
|
|
||||||
/// Sometimes the type of the `content` should be a type alias rather than a struct or enum. This
|
|
||||||
/// is designated with `content_type_alias`:
|
|
||||||
///
|
|
||||||
/// ```ignore
|
|
||||||
/// # pub mod example {
|
|
||||||
/// # use ruma_events_macros::ruma_event;
|
|
||||||
/// ruma_event! {
|
|
||||||
/// /// Informs the client about the rooms that are considered direct by a user.
|
|
||||||
/// DirectEvent {
|
|
||||||
/// kind: Event,
|
|
||||||
/// event_type: Direct,
|
|
||||||
/// content_type_alias: {
|
|
||||||
/// /// The payload of a `DirectEvent`.
|
|
||||||
/// ///
|
|
||||||
/// /// A mapping of `UserId`'s to a collection of `RoomId`'s which are considered
|
|
||||||
/// /// *direct* for that particular user.
|
|
||||||
/// std::collections::BTreeMap<ruma_identifiers::UserId, Vec<ruma_identifiers::RoomId>>
|
|
||||||
/// }
|
|
||||||
/// }
|
|
||||||
/// }
|
|
||||||
/// # }
|
|
||||||
/// ```
|
|
||||||
///
|
|
||||||
/// If `content` and `content_type_alias` are both supplied, the second one listed will overwrite
|
|
||||||
/// the first.
|
|
||||||
///
|
|
||||||
/// The event type and content type will have copies generated inside a private `raw` module. These
|
|
||||||
/// "raw" versions are the same, except they implement `serde::Deserialize`. An implementation of
|
|
||||||
/// `FromRaw` will be provided, which will allow the user to deserialize the event type as
|
|
||||||
/// `EventJson<EventType>`.
|
|
||||||
#[proc_macro]
|
|
||||||
pub fn ruma_event(input: TokenStream) -> TokenStream {
|
|
||||||
let ruma_event_input = syn::parse_macro_input!(input as RumaEventInput);
|
|
||||||
|
|
||||||
let ruma_event = RumaEvent::from(ruma_event_input);
|
|
||||||
|
|
||||||
ruma_event.into_token_stream().into()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Generates an enum to represent the various Matrix event types.
|
/// Generates an enum to represent the various Matrix event types.
|
||||||
///
|
///
|
||||||
|
@ -1,254 +0,0 @@
|
|||||||
//! Details of parsing input for the `ruma_event` procedural macro.
|
|
||||||
|
|
||||||
use syn::{
|
|
||||||
braced,
|
|
||||||
parse::{self, Parse, ParseStream},
|
|
||||||
token::Colon,
|
|
||||||
Attribute, Expr, ExprLit, Field, FieldValue, Ident, Lit, LitStr, Member, Token, TypePath,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// The entire `ruma_event!` macro structure directly as it appears in the source code..
|
|
||||||
pub struct RumaEventInput {
|
|
||||||
/// Outer attributes on the field, such as a docstring.
|
|
||||||
pub attrs: Vec<Attribute>,
|
|
||||||
|
|
||||||
/// The name of the event.
|
|
||||||
pub name: Ident,
|
|
||||||
|
|
||||||
/// The kind of event, determined by the `kind` field.
|
|
||||||
pub kind: EventKind,
|
|
||||||
|
|
||||||
/// The value for the `type` field in the JSON representation of this event. There needs to be a
|
|
||||||
/// corresponding variant in `ruma_events::EventType` for this event (converted to a valid
|
|
||||||
/// Rust-style type name by stripping `m.`, replacing the remaining dots by underscores and then
|
|
||||||
/// converting from snake_case to CamelCase).
|
|
||||||
pub event_type: LitStr,
|
|
||||||
|
|
||||||
/// Additional named struct fields in the top level event struct.
|
|
||||||
pub fields: Option<Vec<Field>>,
|
|
||||||
|
|
||||||
/// A struct definition or type alias to be used as the event's `content` field.
|
|
||||||
pub content: Content,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Parse for RumaEventInput {
|
|
||||||
fn parse(input: ParseStream<'_>) -> parse::Result<Self> {
|
|
||||||
let attrs = input.call(Attribute::parse_outer)?;
|
|
||||||
let name: Ident = input.parse()?;
|
|
||||||
let body;
|
|
||||||
braced!(body in input);
|
|
||||||
|
|
||||||
let mut kind = None;
|
|
||||||
let mut event_type = None;
|
|
||||||
let mut fields = None;
|
|
||||||
let mut content = None;
|
|
||||||
|
|
||||||
for field_value_inline_struct in
|
|
||||||
body.parse_terminated::<RumaEventField, Token![,]>(RumaEventField::parse)?
|
|
||||||
{
|
|
||||||
match field_value_inline_struct {
|
|
||||||
RumaEventField::Block(field_block) => {
|
|
||||||
let ident = match field_block.member {
|
|
||||||
Member::Named(ident) => ident,
|
|
||||||
Member::Unnamed(_) => panic!("fields with block values in `ruma_event!` must named `content_type_alias`"),
|
|
||||||
};
|
|
||||||
|
|
||||||
if ident == "content_type_alias" {
|
|
||||||
content = Some(Content::Typedef(field_block.typedef));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
RumaEventField::InlineStruct(field_inline_struct) => {
|
|
||||||
let ident = match field_inline_struct.member {
|
|
||||||
Member::Named(ident) => ident,
|
|
||||||
Member::Unnamed(_) => panic!("fields with inline struct values in `ruma_event!` must be named `fields` or `content`."),
|
|
||||||
};
|
|
||||||
|
|
||||||
if ident == "fields" {
|
|
||||||
fields = Some(field_inline_struct.fields);
|
|
||||||
} else if ident == "content" {
|
|
||||||
content = Some(Content::Struct(field_inline_struct.fields));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
RumaEventField::Value(field_value) => {
|
|
||||||
let ident = match field_value.member {
|
|
||||||
Member::Named(ident) => ident,
|
|
||||||
Member::Unnamed(_) => panic!("fields with expression values in `ruma_event!` must be named `kind` or `event_type`, ."),
|
|
||||||
};
|
|
||||||
|
|
||||||
if ident == "kind" {
|
|
||||||
let event_kind = match field_value.expr {
|
|
||||||
Expr::Path(expr_path) => {
|
|
||||||
if expr_path.path.is_ident("Event") {
|
|
||||||
EventKind::Event
|
|
||||||
} else {
|
|
||||||
panic!("value of field `kind` must be one of `Event` or `RoomEvent`");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => panic!(
|
|
||||||
"value of field `kind` is required to be an ident by `ruma_event!`"
|
|
||||||
),
|
|
||||||
};
|
|
||||||
|
|
||||||
kind = Some(event_kind);
|
|
||||||
} else if ident == "event_type" {
|
|
||||||
event_type = Some(match field_value.expr {
|
|
||||||
Expr::Lit(ExprLit { lit: Lit::Str(s), .. }) => s,
|
|
||||||
// TODO: Span info
|
|
||||||
_ => panic!(
|
|
||||||
"value of field `event_type` is required to be a string literal by `ruma_event!`"
|
|
||||||
),
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
panic!("unexpected field-value pair with field name `{}`", ident);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if kind.is_none() {
|
|
||||||
panic!("field `kind` is required by `ruma_event!`");
|
|
||||||
} else if event_type.is_none() {
|
|
||||||
panic!("field `event_type` is required by `ruma_event!`");
|
|
||||||
} else if content.is_none() {
|
|
||||||
panic!(
|
|
||||||
"one field named `content` or `content_type_alias` is required by `ruma_event!`"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(Self {
|
|
||||||
attrs,
|
|
||||||
name,
|
|
||||||
kind: kind.unwrap(),
|
|
||||||
event_type: event_type.unwrap(),
|
|
||||||
fields,
|
|
||||||
content: content.unwrap(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Which kind of event is being generated.
|
|
||||||
///
|
|
||||||
/// Determined by the `kind` field in the macro body.
|
|
||||||
#[derive(PartialEq)]
|
|
||||||
pub enum EventKind {
|
|
||||||
/// A basic event.
|
|
||||||
Event,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Information for generating the type used for the event's `content` field.
|
|
||||||
pub enum Content {
|
|
||||||
/// A struct, e.g. `ExampleEventContent { ... }`.
|
|
||||||
Struct(Vec<Field>),
|
|
||||||
|
|
||||||
/// A type alias, e.g. `type ExampleEventContent = SomeExistingType`
|
|
||||||
Typedef(Typedef),
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The style of field within the macro body.
|
|
||||||
#[allow(clippy::large_enum_variant)]
|
|
||||||
enum RumaEventField {
|
|
||||||
/// The value of a field is a block with a type alias in it.
|
|
||||||
///
|
|
||||||
/// Used for `content_type_alias`.
|
|
||||||
Block(FieldBlock),
|
|
||||||
|
|
||||||
/// The value of a field is a block with named struct fields in it.
|
|
||||||
///
|
|
||||||
/// Used for `content`.
|
|
||||||
InlineStruct(FieldInlineStruct),
|
|
||||||
|
|
||||||
/// A standard named struct field.
|
|
||||||
///
|
|
||||||
/// Used for `kind` and `event_type`.
|
|
||||||
Value(FieldValue),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Parse for RumaEventField {
|
|
||||||
fn parse(input: ParseStream<'_>) -> parse::Result<Self> {
|
|
||||||
let ahead = input.fork();
|
|
||||||
let field_ident: Ident = ahead.parse()?;
|
|
||||||
|
|
||||||
match field_ident.to_string().as_ref() {
|
|
||||||
"content" | "fields" => {
|
|
||||||
let attrs = input.call(Attribute::parse_outer)?;
|
|
||||||
let member = input.parse()?;
|
|
||||||
let colon_token = input.parse()?;
|
|
||||||
let body;
|
|
||||||
braced!(body in input);
|
|
||||||
let fields = body
|
|
||||||
.parse_terminated::<Field, Token![,]>(Field::parse_named)?
|
|
||||||
.into_iter()
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
Ok(RumaEventField::InlineStruct(FieldInlineStruct {
|
|
||||||
attrs,
|
|
||||||
member,
|
|
||||||
colon_token,
|
|
||||||
fields,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
"content_type_alias" => Ok(RumaEventField::Block(FieldBlock {
|
|
||||||
attrs: input.call(Attribute::parse_outer)?,
|
|
||||||
member: input.parse()?,
|
|
||||||
colon_token: input.parse()?,
|
|
||||||
typedef: input.parse()?,
|
|
||||||
})),
|
|
||||||
_ => Ok(RumaEventField::Value(input.parse()?)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The value of a field is a block with a type alias in it.
|
|
||||||
///
|
|
||||||
/// Used for `content_type_alias`.
|
|
||||||
struct FieldBlock {
|
|
||||||
/// Outer attributes on the field, such as a docstring.
|
|
||||||
pub attrs: Vec<Attribute>,
|
|
||||||
|
|
||||||
/// The name of the field.
|
|
||||||
pub member: Member,
|
|
||||||
|
|
||||||
/// The colon that appears between the field name and type.
|
|
||||||
pub colon_token: Colon,
|
|
||||||
|
|
||||||
/// The path to the type that will be used in a type alias for the event's `content` type.
|
|
||||||
pub typedef: Typedef,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The value of a field is a block with named struct fields in it.
|
|
||||||
///
|
|
||||||
/// Used for `content`.
|
|
||||||
struct FieldInlineStruct {
|
|
||||||
/// Outer attributes on the field, such as a docstring.
|
|
||||||
pub attrs: Vec<Attribute>,
|
|
||||||
|
|
||||||
/// The name of the field.
|
|
||||||
pub member: Member,
|
|
||||||
|
|
||||||
/// The colon that appears between the field name and type.
|
|
||||||
pub colon_token: Colon,
|
|
||||||
|
|
||||||
/// The fields that define the `content` struct.
|
|
||||||
pub fields: Vec<Field>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Path to a type to be used in a type alias for an event's `content` type.
|
|
||||||
pub struct Typedef {
|
|
||||||
/// Outer attributes on the field, such as a docstring.
|
|
||||||
pub attrs: Vec<Attribute>,
|
|
||||||
|
|
||||||
/// Path to the type.
|
|
||||||
pub path: TypePath,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Parse for Typedef {
|
|
||||||
fn parse(input: ParseStream<'_>) -> parse::Result<Self> {
|
|
||||||
let body;
|
|
||||||
braced!(body in input);
|
|
||||||
|
|
||||||
Ok(Self {
|
|
||||||
attrs: body.call(Attribute::parse_outer)?,
|
|
||||||
path: body.parse()?,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
49
src/enums.rs
49
src/enums.rs
@ -16,7 +16,11 @@ event_enum! {
|
|||||||
event_enum! {
|
event_enum! {
|
||||||
/// Any ephemeral room event.
|
/// Any ephemeral room event.
|
||||||
name: AnyEphemeralRoomEvent,
|
name: AnyEphemeralRoomEvent,
|
||||||
events: [ "m.typing", "m.receipt" ]
|
events: [
|
||||||
|
"m.fully_read",
|
||||||
|
"m.receipt",
|
||||||
|
"m.typing",
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
event_enum! {
|
event_enum! {
|
||||||
@ -39,20 +43,21 @@ event_enum! {
|
|||||||
events: [
|
events: [
|
||||||
"m.room.aliases",
|
"m.room.aliases",
|
||||||
"m.room.avatar",
|
"m.room.avatar",
|
||||||
// "m.room.canonical_alias",
|
"m.room.canonical_alias",
|
||||||
// "m.room.create",
|
"m.room.create",
|
||||||
// "m.room.encryption",
|
"m.room.encryption",
|
||||||
// "m.room.guest_access",
|
"m.room.guest_access",
|
||||||
// "m.room.history_visibility",
|
"m.room.history_visibility",
|
||||||
// "m.room.join_rules",
|
"m.room.join_rules",
|
||||||
"m.room.member",
|
"m.room.member",
|
||||||
// "m.room.name",
|
"m.room.name",
|
||||||
// "m.room.pinned_events",
|
"m.room.pinned_events",
|
||||||
// "m.room.power_levels",
|
"m.room.power_levels",
|
||||||
// "m.room.server_acl",
|
"m.room.redaction",
|
||||||
// "m.room.third_party_invite",
|
"m.room.server_acl",
|
||||||
// "m.room.tombstone",
|
"m.room.third_party_invite",
|
||||||
// "m.room.topic",
|
"m.room.tombstone",
|
||||||
|
"m.room.topic",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,14 +67,14 @@ event_enum! {
|
|||||||
events: [
|
events: [
|
||||||
"m.dummy",
|
"m.dummy",
|
||||||
"m.room_key",
|
"m.room_key",
|
||||||
//"m.room_key_request",
|
"m.room_key_request",
|
||||||
//"m.forwarded_room_key",
|
"m.forwarded_room_key",
|
||||||
//"m.key.verification.request",
|
"m.key.verification.request",
|
||||||
"m.key.verification.start",
|
"m.key.verification.start",
|
||||||
//"m.key.verification.cancel",
|
"m.key.verification.cancel",
|
||||||
//"m.key.verification.accept",
|
"m.key.verification.accept",
|
||||||
//"m.key.verification.key",
|
"m.key.verification.key",
|
||||||
//"m.key.verification.mac",
|
"m.key.verification.mac",
|
||||||
//"m.room.encrypted",
|
"m.room.encrypted",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,21 @@
|
|||||||
//! Types for the *m.forwarded_room_key* event.
|
//! Types for the *m.forwarded_room_key* event.
|
||||||
|
|
||||||
use ruma_events_macros::ruma_event;
|
use ruma_events_macros::BasicEventContent;
|
||||||
use ruma_identifiers::RoomId;
|
use ruma_identifiers::RoomId;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use super::Algorithm;
|
use super::Algorithm;
|
||||||
|
use crate::BasicEvent;
|
||||||
|
|
||||||
ruma_event! {
|
/// This event type is used to forward keys for end-to-end encryption.
|
||||||
/// This event type is used to forward keys for end-to-end encryption.
|
///
|
||||||
///
|
/// Typically it is encrypted as an *m.room.encrypted* event, then sent as a to-device event.
|
||||||
/// Typically it is encrypted as an *m.room.encrypted* event, then sent as a to-device event.
|
pub type ForwardedRoomKeyEvent = BasicEvent<ForwardedRoomKeyEventContent>;
|
||||||
ForwardedRoomKeyEvent {
|
|
||||||
kind: Event,
|
/// The payload for `ForwardedRoomKeyEvent`.
|
||||||
event_type: "m.forwarded_room_key",
|
#[derive(Clone, Debug, Deserialize, Serialize, BasicEventContent)]
|
||||||
content: {
|
#[ruma_event(type = "m.forwarded_room_key")]
|
||||||
|
pub struct ForwardedRoomKeyEventContent {
|
||||||
/// The encryption algorithm the key in this event is to be used with.
|
/// The encryption algorithm the key in this event is to be used with.
|
||||||
pub algorithm: Algorithm,
|
pub algorithm: Algorithm,
|
||||||
|
|
||||||
@ -42,6 +45,4 @@ ruma_event! {
|
|||||||
/// key is forwarded from A to B to C, this field is empty between A and B, and contains
|
/// key is forwarded from A to B to C, this field is empty between A and B, and contains
|
||||||
/// A's Curve25519 key between B and C.
|
/// A's Curve25519 key between B and C.
|
||||||
pub forwarding_curve25519_key_chain: Vec<String>,
|
pub forwarding_curve25519_key_chain: Vec<String>,
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,21 @@
|
|||||||
//! Types for the *m.fully_read* event.
|
//! Types for the *m.fully_read* event.
|
||||||
|
|
||||||
use ruma_events_macros::ruma_event;
|
use ruma_events_macros::EphemeralRoomEventContent;
|
||||||
use ruma_identifiers::{EventId, RoomId};
|
use ruma_identifiers::EventId;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
ruma_event! {
|
use crate::EphemeralRoomEvent;
|
||||||
/// The current location of the user's read marker in a room.
|
|
||||||
///
|
/// The current location of the user's read marker in a room.
|
||||||
/// This event appears in the user's room account data for the room the marker is applicable
|
///
|
||||||
/// for.
|
/// This event appears in the user's room account data for the room the marker is applicable
|
||||||
FullyReadEvent {
|
/// for.
|
||||||
kind: Event,
|
pub type FullyReadEvent = EphemeralRoomEvent<FullyReadEventContent>;
|
||||||
event_type: "m.fully_read",
|
|
||||||
fields: {
|
/// The payload for `FullyReadEvent`.
|
||||||
/// The unique identifier for the room associated with this event.
|
#[derive(Clone, Debug, Deserialize, Serialize, EphemeralRoomEventContent)]
|
||||||
///
|
#[ruma_event(type = "m.fully_read")]
|
||||||
/// `None` if the room is known through other means (such as this even being part of an
|
pub struct FullyReadEventContent {
|
||||||
/// event list scoped to a room in a `/sync` response)
|
|
||||||
pub room_id: Option<RoomId>,
|
|
||||||
},
|
|
||||||
content: {
|
|
||||||
/// The event the user's read marker is located at in the room.
|
/// The event the user's read marker is located at in the room.
|
||||||
pub event_id: EventId,
|
pub event_id: EventId,
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,23 @@
|
|||||||
//! Types for the *m.key.verification.accept* event.
|
//! Types for the *m.key.verification.accept* event.
|
||||||
|
|
||||||
use ruma_events_macros::ruma_event;
|
use ruma_events_macros::BasicEventContent;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
HashAlgorithm, KeyAgreementProtocol, MessageAuthenticationCode, ShortAuthenticationString,
|
HashAlgorithm, KeyAgreementProtocol, MessageAuthenticationCode, ShortAuthenticationString,
|
||||||
VerificationMethod,
|
VerificationMethod,
|
||||||
};
|
};
|
||||||
|
use crate::BasicEvent;
|
||||||
|
|
||||||
ruma_event! {
|
/// Accepts a previously sent *m.key.verification.start* message.
|
||||||
/// Accepts a previously sent *m.key.verification.start* messge.
|
///
|
||||||
///
|
/// Typically sent as a to-device event.
|
||||||
/// Typically sent as a to-device event.
|
pub type AcceptEvent = BasicEvent<AcceptEventContent>;
|
||||||
AcceptEvent {
|
|
||||||
kind: Event,
|
/// The payload for `AcceptEvent`.
|
||||||
event_type: "m.key.verification.accept",
|
#[derive(Clone, Debug, Deserialize, Serialize, BasicEventContent)]
|
||||||
content: {
|
#[ruma_event(type = "m.key.verification.accept")]
|
||||||
|
pub struct AcceptEventContent {
|
||||||
/// An opaque identifier for the verification process.
|
/// An opaque identifier for the verification process.
|
||||||
///
|
///
|
||||||
/// Must be the same as the one used for the *m.key.verification.start* message.
|
/// Must be the same as the one used for the *m.key.verification.start* message.
|
||||||
@ -46,6 +49,4 @@ ruma_event! {
|
|||||||
/// key (encoded as unpadded base64) and the canonical JSON representation of the
|
/// key (encoded as unpadded base64) and the canonical JSON representation of the
|
||||||
/// *m.key.verification.start* message.
|
/// *m.key.verification.start* message.
|
||||||
pub commitment: String,
|
pub commitment: String,
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,17 +2,20 @@
|
|||||||
|
|
||||||
use std::fmt::{Display, Formatter, Result as FmtResult};
|
use std::fmt::{Display, Formatter, Result as FmtResult};
|
||||||
|
|
||||||
use ruma_events_macros::ruma_event;
|
use ruma_events_macros::BasicEventContent;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
ruma_event! {
|
use crate::BasicEvent;
|
||||||
/// Cancels a key verification process/request.
|
|
||||||
///
|
/// Cancels a key verification process/request.
|
||||||
/// Typically sent as a to-device event.
|
///
|
||||||
CancelEvent {
|
/// Typically sent as a to-device event.
|
||||||
kind: Event,
|
pub type CancelEvent = BasicEvent<CancelEventContent>;
|
||||||
event_type: "m.key.verification.cancel",
|
|
||||||
content: {
|
/// The payload for `CancelEvent`.
|
||||||
|
#[derive(Clone, Debug, Deserialize, Serialize, BasicEventContent)]
|
||||||
|
#[ruma_event(type = "m.key.verification.cancel")]
|
||||||
|
pub struct CancelEventContent {
|
||||||
/// The opaque identifier for the verification process/request.
|
/// The opaque identifier for the verification process/request.
|
||||||
pub transaction_id: String,
|
pub transaction_id: String,
|
||||||
|
|
||||||
@ -23,8 +26,6 @@ ruma_event! {
|
|||||||
|
|
||||||
/// The error code for why the process/request was cancelled by the user.
|
/// The error code for why the process/request was cancelled by the user.
|
||||||
pub code: CancelCode,
|
pub code: CancelCode,
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An error code for why the process/request was cancelled by the user.
|
/// An error code for why the process/request was cancelled by the user.
|
||||||
|
@ -1,15 +1,19 @@
|
|||||||
//! Types for the *m.key.verification.key* event.
|
//! Types for the *m.key.verification.key* event.
|
||||||
|
|
||||||
use ruma_events_macros::ruma_event;
|
use ruma_events_macros::BasicEventContent;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
ruma_event! {
|
use crate::BasicEvent;
|
||||||
/// Sends the ephemeral public key for a device to the partner device.
|
|
||||||
///
|
/// Sends the ephemeral public key for a device to the partner device.
|
||||||
/// Typically sent as a to-device event.
|
///
|
||||||
KeyEvent {
|
/// Typically sent as a to-device event.
|
||||||
kind: Event,
|
pub type KeyEvent = BasicEvent<KeyEventContent>;
|
||||||
event_type: "m.key.verification.key",
|
|
||||||
content: {
|
/// The payload for `KeyEvent`.
|
||||||
|
#[derive(Clone, Debug, Deserialize, Serialize, BasicEventContent)]
|
||||||
|
#[ruma_event(type = "m.key.verification.key")]
|
||||||
|
pub struct KeyEventContent {
|
||||||
/// An opaque identifier for the verification process.
|
/// An opaque identifier for the verification process.
|
||||||
///
|
///
|
||||||
/// Must be the same as the one used for the *m.key.verification.start* message.
|
/// Must be the same as the one used for the *m.key.verification.start* message.
|
||||||
@ -17,6 +21,4 @@ ruma_event! {
|
|||||||
|
|
||||||
/// The device's ephemeral public key, encoded as unpadded Base64.
|
/// The device's ephemeral public key, encoded as unpadded Base64.
|
||||||
pub key: String,
|
pub key: String,
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,16 +2,20 @@
|
|||||||
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use ruma_events_macros::ruma_event;
|
use ruma_events_macros::BasicEventContent;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
ruma_event! {
|
use crate::BasicEvent;
|
||||||
/// Sends the MAC of a device's key to the partner device.
|
|
||||||
///
|
/// Sends the MAC of a device's key to the partner device.
|
||||||
/// Typically sent as a to-device event.
|
///
|
||||||
MacEvent {
|
/// Typically sent as a to-device event.
|
||||||
kind: Event,
|
pub type MacEvent = BasicEvent<MacEventContent>;
|
||||||
event_type: "m.key.verification.mac",
|
|
||||||
content: {
|
/// The payload for `MacEvent`.
|
||||||
|
#[derive(Clone, Debug, Deserialize, Serialize, BasicEventContent)]
|
||||||
|
#[ruma_event(type = "m.key.verification.mac")]
|
||||||
|
pub struct MacEventContent {
|
||||||
/// An opaque identifier for the verification process.
|
/// An opaque identifier for the verification process.
|
||||||
///
|
///
|
||||||
/// Must be the same as the one used for the *m.key.verification.start* message.
|
/// Must be the same as the one used for the *m.key.verification.start* message.
|
||||||
@ -25,6 +29,4 @@ ruma_event! {
|
|||||||
/// The MAC of the comma-separated, sorted, list of key IDs given in the `mac` property, encoded
|
/// The MAC of the comma-separated, sorted, list of key IDs given in the `mac` property, encoded
|
||||||
/// as unpadded Base64.
|
/// as unpadded Base64.
|
||||||
pub keys: String,
|
pub keys: String,
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,19 +2,22 @@
|
|||||||
|
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
|
|
||||||
use ruma_events_macros::ruma_event;
|
use ruma_events_macros::BasicEventContent;
|
||||||
use ruma_identifiers::DeviceId;
|
use ruma_identifiers::DeviceId;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use super::VerificationMethod;
|
use super::VerificationMethod;
|
||||||
|
use crate::BasicEvent;
|
||||||
|
|
||||||
ruma_event! {
|
/// Requests a key verification with another user's devices.
|
||||||
/// Requests a key verification with another user's devices.
|
///
|
||||||
///
|
/// Typically sent as a to-device event.
|
||||||
/// Typically sent as a to-device event.
|
pub type RequestEvent = BasicEvent<RequestEventContent>;
|
||||||
RequestEvent {
|
|
||||||
kind: Event,
|
/// The payload for `RequestEvent`.
|
||||||
event_type: "m.key.verification.request",
|
#[derive(Clone, Debug, Deserialize, Serialize, BasicEventContent)]
|
||||||
content: {
|
#[ruma_event(type = "m.key.verification.request")]
|
||||||
|
pub struct RequestEventContent {
|
||||||
/// The device ID which is initiating the request.
|
/// The device ID which is initiating the request.
|
||||||
pub from_device: DeviceId,
|
pub from_device: DeviceId,
|
||||||
|
|
||||||
@ -32,6 +35,4 @@ ruma_event! {
|
|||||||
/// the past, the message should be ignored by the receiver.
|
/// the past, the message should be ignored by the receiver.
|
||||||
#[serde(with = "ruma_serde::time::ms_since_unix_epoch")]
|
#[serde(with = "ruma_serde::time::ms_since_unix_epoch")]
|
||||||
pub timestamp: SystemTime,
|
pub timestamp: SystemTime,
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ pub use ruma_common::push::Action;
|
|||||||
/// room, or by default. The push ruleset contains the entire set of scopes and rules.
|
/// room, or by default. The push ruleset contains the entire set of scopes and rules.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct Ruleset {
|
pub struct Ruleset {
|
||||||
/// These rules configure behaviour for (unencrypted) messages that match certain patterns.
|
/// These rules configure behavior for (unencrypted) messages that match certain patterns.
|
||||||
pub content: Vec<PatternedPushRule>,
|
pub content: Vec<PatternedPushRule>,
|
||||||
|
|
||||||
/// These user-configured rules are given the highest priority.
|
/// These user-configured rules are given the highest priority.
|
||||||
@ -34,10 +34,10 @@ pub struct Ruleset {
|
|||||||
#[serde(rename = "override")]
|
#[serde(rename = "override")]
|
||||||
pub override_: Vec<ConditionalPushRule>,
|
pub override_: Vec<ConditionalPushRule>,
|
||||||
|
|
||||||
/// These rules change the behaviour of all messages for a given room.
|
/// These rules change the behavior of all messages for a given room.
|
||||||
pub room: Vec<PushRule>,
|
pub room: Vec<PushRule>,
|
||||||
|
|
||||||
/// These rules configure notification behaviour for messages from a specific Matrix user ID.
|
/// These rules configure notification behavior for messages from a specific Matrix user ID.
|
||||||
pub sender: Vec<PushRule>,
|
pub sender: Vec<PushRule>,
|
||||||
|
|
||||||
/// These rules are identical to override rules, but have a lower priority than `content`,
|
/// These rules are identical to override rules, but have a lower priority than `content`,
|
||||||
|
@ -4,7 +4,12 @@ use ruma_events_macros::StateEventContent;
|
|||||||
use ruma_identifiers::RoomAliasId;
|
use ruma_identifiers::RoomAliasId;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::StateEvent;
|
||||||
|
|
||||||
/// Informs the room as to which alias is the canonical one.
|
/// Informs the room as to which alias is the canonical one.
|
||||||
|
pub type CanonicalAliasEvent = StateEvent<CanonicalAliasEventContent>;
|
||||||
|
|
||||||
|
/// The payload for `CanonicalAliasEvent`.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)]
|
#[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)]
|
||||||
#[ruma_event(type = "m.room.canonical_alias")]
|
#[ruma_event(type = "m.room.canonical_alias")]
|
||||||
pub struct CanonicalAliasEventContent {
|
pub struct CanonicalAliasEventContent {
|
||||||
|
@ -6,8 +6,13 @@ use ruma_events_macros::StateEventContent;
|
|||||||
use ruma_identifiers::{EventId, RoomId, RoomVersionId, UserId};
|
use ruma_identifiers::{EventId, RoomId, RoomVersionId, UserId};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::StateEvent;
|
||||||
|
|
||||||
/// This is the first event in a room and cannot be changed. It acts as the root of all other
|
/// This is the first event in a room and cannot be changed. It acts as the root of all other
|
||||||
/// events.
|
/// events.
|
||||||
|
pub type CreateEvent = StateEvent<CreateEventContent>;
|
||||||
|
|
||||||
|
/// The payload for `CreateEvent`.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)]
|
#[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)]
|
||||||
#[ruma_event(type = "m.room.create")]
|
#[ruma_event(type = "m.room.create")]
|
||||||
pub struct CreateEventContent {
|
pub struct CreateEventContent {
|
||||||
|
@ -1,16 +1,21 @@
|
|||||||
//! Types for the *m.room.encrypted* event.
|
//! Types for the *m.room.encrypted* event.
|
||||||
|
|
||||||
use std::{collections::BTreeMap, time::SystemTime};
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
use ruma_identifiers::{DeviceId, EventId, RoomId, UserId};
|
use ruma_events_macros::StateEventContent;
|
||||||
|
use ruma_identifiers::DeviceId;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::UnsignedData;
|
use crate::StateEvent;
|
||||||
|
|
||||||
|
/// An event that defines how messages sent in this room should be encrypted.
|
||||||
|
pub type EncryptedEvent = StateEvent<EncryptedEventContent>;
|
||||||
|
|
||||||
/// The payload for `EncryptedEvent`.
|
/// The payload for `EncryptedEvent`.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
|
#[ruma_event(type = "m.room.encrypted")]
|
||||||
#[serde(tag = "algorithm")]
|
#[serde(tag = "algorithm")]
|
||||||
pub enum EncryptedEventContent {
|
pub enum EncryptedEventContent {
|
||||||
/// An event encrypted with *m.olm.v1.curve25519-aes-sha2*.
|
/// An event encrypted with *m.olm.v1.curve25519-aes-sha2*.
|
||||||
|
@ -4,9 +4,12 @@ use js_int::UInt;
|
|||||||
use ruma_events_macros::StateEventContent;
|
use ruma_events_macros::StateEventContent;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::Algorithm;
|
use crate::{Algorithm, StateEvent};
|
||||||
|
|
||||||
/// Defines how messages sent in this room should be encrypted.
|
/// Defines how messages sent in this room should be encrypted.
|
||||||
|
pub type EncryptionEvent = StateEvent<EncryptionEventContent>;
|
||||||
|
|
||||||
|
/// The payload for `EncryptionEvent`.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)]
|
#[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)]
|
||||||
#[ruma_event(type = "m.room.encryption")]
|
#[ruma_event(type = "m.room.encryption")]
|
||||||
pub struct EncryptionEventContent {
|
pub struct EncryptionEventContent {
|
||||||
|
@ -4,10 +4,15 @@ use ruma_events_macros::StateEventContent;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use strum::{Display, EnumString};
|
use strum::{Display, EnumString};
|
||||||
|
|
||||||
|
use crate::StateEvent;
|
||||||
|
|
||||||
/// Controls whether guest users are allowed to join rooms.
|
/// Controls whether guest users are allowed to join rooms.
|
||||||
///
|
///
|
||||||
/// This event controls whether guest users are allowed to join rooms. If this event is absent,
|
/// This event controls whether guest users are allowed to join rooms. If this event is absent,
|
||||||
/// servers should act as if it is present and has the value `GuestAccess::Forbidden`.
|
/// servers should act as if it is present and has the value `GuestAccess::Forbidden`.
|
||||||
|
pub type GuestAccessEvent = StateEvent<GuestAccessEventContent>;
|
||||||
|
|
||||||
|
/// The payload for `GuestAccessEvent`.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)]
|
#[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)]
|
||||||
#[ruma_event(type = "m.room.guest_access")]
|
#[ruma_event(type = "m.room.guest_access")]
|
||||||
pub struct GuestAccessEventContent {
|
pub struct GuestAccessEventContent {
|
||||||
|
@ -4,8 +4,13 @@ use ruma_events_macros::StateEventContent;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use strum::{Display, EnumString};
|
use strum::{Display, EnumString};
|
||||||
|
|
||||||
|
use crate::StateEvent;
|
||||||
|
|
||||||
/// This event controls whether a member of a room can see the events that happened in a room
|
/// This event controls whether a member of a room can see the events that happened in a room
|
||||||
/// from before they joined.
|
/// from before they joined.
|
||||||
|
pub type HistoryVisibilityEvent = StateEvent<HistoryVisibilityEventContent>;
|
||||||
|
|
||||||
|
/// The payload for `HistoryVisibilityEvent`.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)]
|
#[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)]
|
||||||
#[ruma_event(type = "m.room.history_visibility")]
|
#[ruma_event(type = "m.room.history_visibility")]
|
||||||
pub struct HistoryVisibilityEventContent {
|
pub struct HistoryVisibilityEventContent {
|
||||||
|
@ -4,7 +4,12 @@ use ruma_events_macros::StateEventContent;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use strum::{Display, EnumString};
|
use strum::{Display, EnumString};
|
||||||
|
|
||||||
|
use crate::StateEvent;
|
||||||
|
|
||||||
/// Describes how users are allowed to join the room.
|
/// Describes how users are allowed to join the room.
|
||||||
|
pub type JoinRulesEvent = StateEvent<JoinRulesEventContent>;
|
||||||
|
|
||||||
|
/// The payload for `JoinRulesEvent`.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)]
|
#[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)]
|
||||||
#[ruma_event(type = "m.room.join_rules")]
|
#[ruma_event(type = "m.room.join_rules")]
|
||||||
pub struct JoinRulesEventContent {
|
pub struct JoinRulesEventContent {
|
||||||
|
@ -3,7 +3,10 @@
|
|||||||
use ruma_events_macros::StateEventContent;
|
use ruma_events_macros::StateEventContent;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::InvalidInput;
|
use crate::{InvalidInput, StateEvent};
|
||||||
|
|
||||||
|
/// The room name is a human-friendly string designed to be displayed to the end-user.
|
||||||
|
pub type NameEvent = StateEvent<NameEventContent>;
|
||||||
|
|
||||||
/// The payload for `NameEvent`.
|
/// The payload for `NameEvent`.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)]
|
#[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)]
|
||||||
|
@ -4,7 +4,12 @@ use ruma_events_macros::StateEventContent;
|
|||||||
use ruma_identifiers::EventId;
|
use ruma_identifiers::EventId;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::StateEvent;
|
||||||
|
|
||||||
/// Used to "pin" particular events in a room for other participants to review later.
|
/// Used to "pin" particular events in a room for other participants to review later.
|
||||||
|
pub type PinnedEventsEvent = StateEvent<PinnedEventsEventContent>;
|
||||||
|
|
||||||
|
/// The payload for `PinnedEventsEvent`.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)]
|
#[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)]
|
||||||
#[ruma_event(type = "m.room.pinned_events")]
|
#[ruma_event(type = "m.room.pinned_events")]
|
||||||
pub struct PinnedEventsEventContent {
|
pub struct PinnedEventsEventContent {
|
||||||
|
@ -7,9 +7,12 @@ use ruma_events_macros::StateEventContent;
|
|||||||
use ruma_identifiers::UserId;
|
use ruma_identifiers::UserId;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::EventType;
|
use crate::{EventType, StateEvent};
|
||||||
|
|
||||||
/// Defines the power levels (privileges) of users in the room.
|
/// Defines the power levels (privileges) of users in the room.
|
||||||
|
pub type PowerLevelsEvent = StateEvent<PowerLevelsEventContent>;
|
||||||
|
|
||||||
|
/// The payload for `PowerLevelsEvent`.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)]
|
#[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)]
|
||||||
#[ruma_event(type = "m.room.power_levels")]
|
#[ruma_event(type = "m.room.power_levels")]
|
||||||
pub struct PowerLevelsEventContent {
|
pub struct PowerLevelsEventContent {
|
||||||
|
@ -3,7 +3,12 @@
|
|||||||
use ruma_events_macros::StateEventContent;
|
use ruma_events_macros::StateEventContent;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::StateEvent;
|
||||||
|
|
||||||
/// An event to indicate which servers are permitted to participate in the room.
|
/// An event to indicate which servers are permitted to participate in the room.
|
||||||
|
pub type ServerAclEvent = StateEvent<ServerAclEventContent>;
|
||||||
|
|
||||||
|
/// The payload for `ServerAclEvent`.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)]
|
#[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)]
|
||||||
#[ruma_event(type = "m.room.server_acl")]
|
#[ruma_event(type = "m.room.server_acl")]
|
||||||
pub struct ServerAclEventContent {
|
pub struct ServerAclEventContent {
|
||||||
|
@ -3,11 +3,16 @@
|
|||||||
use ruma_events_macros::StateEventContent;
|
use ruma_events_macros::StateEventContent;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::StateEvent;
|
||||||
|
|
||||||
/// An invitation to a room issued to a third party identifier, rather than a matrix user ID.
|
/// An invitation to a room issued to a third party identifier, rather than a matrix user ID.
|
||||||
///
|
///
|
||||||
/// Acts as an *m.room.member* invite event, where there isn't a target user_id to invite. This
|
/// Acts as an *m.room.member* invite event, where there isn't a target user_id to invite. This
|
||||||
/// event contains a token and a public key whose private key must be used to sign the token.
|
/// event contains a token and a public key whose private key must be used to sign the token.
|
||||||
/// Any user who can present that signature may use this invitation to join the target room.
|
/// Any user who can present that signature may use this invitation to join the target room.
|
||||||
|
pub type ThirdPartyInviteEvent = StateEvent<ThirdPartyInviteEventContent>;
|
||||||
|
|
||||||
|
/// The payload for `ThirdPartyInviteEvent`.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)]
|
#[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)]
|
||||||
#[ruma_event(type = "m.room.third_party_invite")]
|
#[ruma_event(type = "m.room.third_party_invite")]
|
||||||
pub struct ThirdPartyInviteEventContent {
|
pub struct ThirdPartyInviteEventContent {
|
||||||
|
@ -4,8 +4,13 @@ use ruma_events_macros::StateEventContent;
|
|||||||
use ruma_identifiers::RoomId;
|
use ruma_identifiers::RoomId;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::StateEvent;
|
||||||
|
|
||||||
/// A state event signifying that a room has been upgraded to a different room version, and that
|
/// A state event signifying that a room has been upgraded to a different room version, and that
|
||||||
/// clients should go there.
|
/// clients should go there.
|
||||||
|
pub type TombstoneEvent = StateEvent<TombstoneEventContent>;
|
||||||
|
|
||||||
|
/// The payload for `TombstoneEvent`.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)]
|
#[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)]
|
||||||
#[ruma_event(type = "m.room.tombstone")]
|
#[ruma_event(type = "m.room.tombstone")]
|
||||||
pub struct TombstoneEventContent {
|
pub struct TombstoneEventContent {
|
||||||
|
@ -3,7 +3,12 @@
|
|||||||
use ruma_events_macros::StateEventContent;
|
use ruma_events_macros::StateEventContent;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::StateEvent;
|
||||||
|
|
||||||
/// A topic is a short message detailing what is currently being discussed in the room.
|
/// A topic is a short message detailing what is currently being discussed in the room.
|
||||||
|
pub type TopicEvent = StateEvent<TopicEventContent>;
|
||||||
|
|
||||||
|
/// The payload for `TopicEvent`.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)]
|
#[derive(Clone, Debug, Deserialize, Serialize, StateEventContent)]
|
||||||
#[ruma_event(type = "m.room.topic")]
|
#[ruma_event(type = "m.room.topic")]
|
||||||
pub struct TopicEventContent {
|
pub struct TopicEventContent {
|
||||||
|
@ -1,20 +1,22 @@
|
|||||||
//! Types for the *m.room_key_request* event.
|
//! Types for the *m.room_key_request* event.
|
||||||
|
|
||||||
use ruma_events_macros::ruma_event;
|
use ruma_events_macros::BasicEventContent;
|
||||||
use ruma_identifiers::{DeviceId, RoomId};
|
use ruma_identifiers::{DeviceId, RoomId};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use strum::{Display, EnumString};
|
use strum::{Display, EnumString};
|
||||||
|
|
||||||
use super::Algorithm;
|
use super::Algorithm;
|
||||||
|
use crate::BasicEvent;
|
||||||
|
|
||||||
ruma_event! {
|
/// This event type is used to request keys for end-to-end encryption.
|
||||||
/// This event type is used to request keys for end-to-end encryption.
|
///
|
||||||
///
|
/// It is sent as an unencrypted to-device event.
|
||||||
/// It is sent as an unencrypted to-device event.
|
pub type RoomKeyRequestEvent = BasicEvent<RoomKeyRequestEventContent>;
|
||||||
RoomKeyRequestEvent {
|
|
||||||
kind: Event,
|
/// The payload for `RoomKeyRequestEvent`.
|
||||||
event_type: "m.room_key_request",
|
#[derive(Clone, Debug, Deserialize, Serialize, BasicEventContent)]
|
||||||
content: {
|
#[ruma_event(type = "m.room_key_request")]
|
||||||
|
pub struct RoomKeyRequestEventContent {
|
||||||
/// Whether this is a new key request or a cancellation of a previous request.
|
/// Whether this is a new key request or a cancellation of a previous request.
|
||||||
pub action: Action,
|
pub action: Action,
|
||||||
|
|
||||||
@ -31,8 +33,6 @@ ruma_event! {
|
|||||||
/// If the key is requested multiple times, it should be reused. It should also reused
|
/// If the key is requested multiple times, it should be reused. It should also reused
|
||||||
/// in order to cancel a request.
|
/// in order to cancel a request.
|
||||||
pub request_id: String,
|
pub request_id: String,
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A new key request or a cancellation of a previous request.
|
/// A new key request or a cancellation of a previous request.
|
||||||
|
@ -2,10 +2,11 @@
|
|||||||
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use crate::BasicEvent;
|
|
||||||
use ruma_events_macros::BasicEventContent;
|
use ruma_events_macros::BasicEventContent;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::BasicEvent;
|
||||||
|
|
||||||
/// Informs the client of tags on a room.
|
/// Informs the client of tags on a room.
|
||||||
pub type TagEvent = BasicEvent<TagEventContent>;
|
pub type TagEvent = BasicEvent<TagEventContent>;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user