diff --git a/Cargo.toml b/Cargo.toml index ca29e539..5cc90888 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -authors = ["Jimmy Cuadra "] +authors = ["Jonas Platte "] 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" diff --git a/src/lib.rs b/src/lib.rs index 8b137891..b2189a10 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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, + pub prev_events: Vec, + pub depth: UInt, + pub auth_events: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + pub redacts: Option, + #[serde(default, skip_serializing_if = "serde_json::Map::is_empty")] + pub unsigned: serde_json::Map, + pub hashes: EventHash, + pub signatures: HashMap>, +} + +#[derive(Deserialize, Serialize)] +pub struct EventHash { + pub sha256: String, +}