Add PDU type for v3 rooms and above

This commit is contained in:
Jonas Platte 2020-04-01 21:27:10 +02:00
parent 2877fde4ad
commit dbc8312730
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
2 changed files with 45 additions and 1 deletions

View File

@ -1,5 +1,5 @@
[package]
authors = ["Jimmy Cuadra <jimmy@jimmycuadra.com>"]
authors = ["Jonas Platte <jplatte+git@posteo.de>"]
categories = ["api-bindings", "web-programming"]
description = "Types for the endpoints in the Matrix server-server API."
documentation = "https://docs.rs/ruma-federation-api"
@ -13,3 +13,8 @@ repository = "https://github.com/ruma/ruma-federation-api"
version = "0.1.0"
[dependencies]
js_int = "0.1.3"
ruma-events = "0.18.0"
ruma-identifiers = "0.14.1"
serde = { version = "1.0.105", features = ["derive"] }
serde_json = "1.0.50"

View File

@ -1 +1,40 @@
// TODO
//!#[warn(missing_docs)]
use std::collections::HashMap;
use js_int::UInt;
use ruma_events::EventType;
use ruma_identifiers::{EventId, RoomId, UserId};
use serde::{Deserialize, Serialize};
use serde_json::Value as JsonValue;
#[derive(Deserialize, Serialize)]
pub struct RoomV3Pdu {
pub room_id: RoomId,
pub sender: UserId,
pub origin: String,
pub origin_server_ts: UInt,
// TODO: Replace with event content collection from ruma-events once that exists
#[serde(rename = "type")]
pub kind: EventType,
pub content: JsonValue,
#[serde(skip_serializing_if = "Option::is_none")]
pub state_key: Option<String>,
pub prev_events: Vec<EventId>,
pub depth: UInt,
pub auth_events: Vec<EventId>,
#[serde(skip_serializing_if = "Option::is_none")]
pub redacts: Option<EventId>,
#[serde(default, skip_serializing_if = "serde_json::Map::is_empty")]
pub unsigned: serde_json::Map<String, JsonValue>,
pub hashes: EventHash,
pub signatures: HashMap<String, HashMap<String, String>>,
}
#[derive(Deserialize, Serialize)]
pub struct EventHash {
pub sha256: String,
}