From de7045fa9d91810f4bec7248e33cd08a962a0628 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Thu, 2 Apr 2020 11:50:53 +0200 Subject: [PATCH] Add docs --- src/lib.rs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 8ecf4e17..bd98af77 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,6 @@ -// TODO -// !#[warn(missing_docs)] +//! (De)serializable types for the matrix server-server protocol. + +#![warn(missing_docs)] use std::collections::HashMap; @@ -9,32 +10,53 @@ use ruma_identifiers::{EventId, RoomId, UserId}; use serde::{Deserialize, Serialize}; use serde_json::Value as JsonValue; +/// A 'persistent data unit' (event) for room versions 3 and beyond. #[derive(Deserialize, Serialize)] pub struct RoomV3Pdu { + /// The room this event belongs to. pub room_id: RoomId, + /// The user id of the user who sent this event. pub sender: UserId, + /// The `server_name` of the homeserver that created this event. pub origin: String, + /// Timestamp (milliseconds since the UNIX epoch) on originating homeserver + /// of when this event was created. pub origin_server_ts: UInt, // TODO: Replace with event content collection from ruma-events once that exists + /// The event's type. #[serde(rename = "type")] pub kind: EventType, + /// The event's content. pub content: JsonValue, + /// A key that determines which piece of room state the event represents. #[serde(skip_serializing_if = "Option::is_none")] pub state_key: Option, + /// Event IDs for the most recent events in the room that the homeserver was + /// aware of when it created this event. pub prev_events: Vec, + /// The maximum depth of the `prev_events`, plus one. pub depth: UInt, + /// Event IDs for the authorization events that would allow this event to be + /// in the room. pub auth_events: Vec, + /// For redaction events, the ID of the event being redacted. #[serde(skip_serializing_if = "Option::is_none")] pub redacts: Option, + /// Additional data added by the origin server but not covered by the + /// signatures. #[serde(default, skip_serializing_if = "serde_json::Map::is_empty")] pub unsigned: serde_json::Map, + /// Content hashes of the PDU. pub hashes: EventHash, + /// Signatures for the PDU. pub signatures: HashMap>, } +/// Content hashes of a PDU. #[derive(Deserialize, Serialize)] pub struct EventHash { + /// The SHA-256 hash. pub sha256: String, }