commit 2b01d34a6775845a7d57ed966e95f6d3672b86de
Author: MTRNord <mtrnord1@gmail.com>
Date: Sat, 16 Apr 2022 20:23:30 +0200
Initial matrix event schema and test code
Diffstat:
8 files changed, 734 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1,3 @@
+/target
+/data
+/json_data
+\ No newline at end of file
diff --git a/Cargo.lock b/Cargo.lock
@@ -0,0 +1,462 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "addr2line"
+version = "0.17.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b"
+dependencies = [
+ "gimli",
+]
+
+[[package]]
+name = "adler"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
+
+[[package]]
+name = "atty"
+version = "0.2.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
+dependencies = [
+ "hermit-abi",
+ "libc",
+ "winapi",
+]
+
+[[package]]
+name = "autocfg"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
+
+[[package]]
+name = "backtrace"
+version = "0.3.64"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5e121dee8023ce33ab248d9ce1493df03c3b38a659b240096fcbd7048ff9c31f"
+dependencies = [
+ "addr2line",
+ "cc",
+ "cfg-if",
+ "libc",
+ "miniz_oxide",
+ "object",
+ "rustc-demangle",
+]
+
+[[package]]
+name = "bitflags"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
+
+[[package]]
+name = "capnp"
+version = "0.14.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "21d5d7da973146f1720672faa44f1523cc8f923636190ca1a931c7bc8834de68"
+
+[[package]]
+name = "capnpc"
+version = "0.14.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c7ed9b80f792ac01a8b328ccbc509c2bd756fb5dec18af0163e7963dde23c0b5"
+dependencies = [
+ "capnp",
+]
+
+[[package]]
+name = "cc"
+version = "1.0.73"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
+
+[[package]]
+name = "cfg-if"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
+
+[[package]]
+name = "clap"
+version = "3.1.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6aad2534fad53df1cc12519c5cda696dd3e20e6118a027e24054aea14a0bdcbe"
+dependencies = [
+ "atty",
+ "bitflags",
+ "clap_derive",
+ "clap_lex",
+ "indexmap",
+ "lazy_static",
+ "strsim",
+ "termcolor",
+ "textwrap",
+]
+
+[[package]]
+name = "clap_derive"
+version = "3.1.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a3aab4734e083b809aaf5794e14e756d1c798d2c69c7f7de7a09a2f5214993c1"
+dependencies = [
+ "heck",
+ "proc-macro-error",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "clap_lex"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "189ddd3b5d32a70b35e7686054371742a937b0d99128e76dde6340210e966669"
+dependencies = [
+ "os_str_bytes",
+]
+
+[[package]]
+name = "color-eyre"
+version = "0.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ebf286c900a6d5867aeff75cfee3192857bb7f24b547d4f0df2ed6baa812c90"
+dependencies = [
+ "backtrace",
+ "color-spantrace",
+ "eyre",
+ "indenter",
+ "once_cell",
+ "owo-colors",
+ "tracing-error",
+]
+
+[[package]]
+name = "color-spantrace"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1ba75b3d9449ecdccb27ecbc479fdc0b87fa2dd43d2f8298f9bf0e59aacc8dce"
+dependencies = [
+ "once_cell",
+ "owo-colors",
+ "tracing-core",
+ "tracing-error",
+]
+
+[[package]]
+name = "eyre"
+version = "0.6.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4c2b6b5a29c02cdc822728b7d7b8ae1bab3e3b05d44522770ddd49722eeac7eb"
+dependencies = [
+ "indenter",
+ "once_cell",
+]
+
+[[package]]
+name = "gimli"
+version = "0.26.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4"
+
+[[package]]
+name = "hashbrown"
+version = "0.11.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
+
+[[package]]
+name = "heck"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
+
+[[package]]
+name = "hermit-abi"
+version = "0.1.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "indenter"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
+
+[[package]]
+name = "indexmap"
+version = "1.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0f647032dfaa1f8b6dc29bd3edb7bbef4861b8b8007ebb118d6db284fd59f6ee"
+dependencies = [
+ "autocfg",
+ "hashbrown",
+]
+
+[[package]]
+name = "lazy_static"
+version = "1.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
+
+[[package]]
+name = "libc"
+version = "0.2.123"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cb691a747a7ab48abc15c5b42066eaafde10dc427e3b6ee2a1cf43db04c763bd"
+
+[[package]]
+name = "memchr"
+version = "2.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
+
+[[package]]
+name = "miniz_oxide"
+version = "0.4.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b"
+dependencies = [
+ "adler",
+ "autocfg",
+]
+
+[[package]]
+name = "object"
+version = "0.27.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "once_cell"
+version = "1.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9"
+
+[[package]]
+name = "os_str_bytes"
+version = "6.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
+
+[[package]]
+name = "owo-colors"
+version = "3.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5e72e30578e0d0993c8ae20823dd9cff2bc5517d2f586a8aef462a581e8a03eb"
+
+[[package]]
+name = "pin-project-lite"
+version = "0.2.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c"
+
+[[package]]
+name = "proc-macro-error"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
+dependencies = [
+ "proc-macro-error-attr",
+ "proc-macro2",
+ "quote",
+ "syn",
+ "version_check",
+]
+
+[[package]]
+name = "proc-macro-error-attr"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "version_check",
+]
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.37"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1"
+dependencies = [
+ "unicode-xid",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "replayer-mx"
+version = "0.1.0"
+dependencies = [
+ "capnp",
+ "capnpc",
+ "clap",
+ "color-eyre",
+]
+
+[[package]]
+name = "rustc-demangle"
+version = "0.1.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342"
+
+[[package]]
+name = "sharded-slab"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31"
+dependencies = [
+ "lazy_static",
+]
+
+[[package]]
+name = "strsim"
+version = "0.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
+
+[[package]]
+name = "syn"
+version = "1.0.91"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b683b2b825c8eef438b77c36a06dc262294da3d5a5813fac20da149241dcd44d"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-xid",
+]
+
+[[package]]
+name = "termcolor"
+version = "1.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
+dependencies = [
+ "winapi-util",
+]
+
+[[package]]
+name = "textwrap"
+version = "0.15.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
+
+[[package]]
+name = "thread_local"
+version = "1.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180"
+dependencies = [
+ "once_cell",
+]
+
+[[package]]
+name = "tracing"
+version = "0.1.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5d0ecdcb44a79f0fe9844f0c4f33a342cbcbb5117de8001e6ba0dc2351327d09"
+dependencies = [
+ "cfg-if",
+ "pin-project-lite",
+ "tracing-core",
+]
+
+[[package]]
+name = "tracing-core"
+version = "0.1.26"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f54c8ca710e81886d498c2fd3331b56c93aa248d49de2222ad2742247c60072f"
+dependencies = [
+ "lazy_static",
+ "valuable",
+]
+
+[[package]]
+name = "tracing-error"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d686ec1c0f384b1277f097b2f279a2ecc11afe8c133c1aabf036a27cb4cd206e"
+dependencies = [
+ "tracing",
+ "tracing-subscriber",
+]
+
+[[package]]
+name = "tracing-subscriber"
+version = "0.3.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4bc28f93baff38037f64e6f43d34cfa1605f27a49c34e8a04c5e78b0babf2596"
+dependencies = [
+ "sharded-slab",
+ "thread_local",
+ "tracing-core",
+]
+
+[[package]]
+name = "unicode-xid"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
+
+[[package]]
+name = "valuable"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
+
+[[package]]
+name = "version_check"
+version = "0.9.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
+
+[[package]]
+name = "winapi"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
+dependencies = [
+ "winapi-i686-pc-windows-gnu",
+ "winapi-x86_64-pc-windows-gnu",
+]
+
+[[package]]
+name = "winapi-i686-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
+
+[[package]]
+name = "winapi-util"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
+dependencies = [
+ "winapi",
+]
+
+[[package]]
+name = "winapi-x86_64-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
diff --git a/Cargo.toml b/Cargo.toml
@@ -0,0 +1,14 @@
+[package]
+name = "replayer-mx"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+capnp = "0.14"
+color-eyre = "0.6"
+clap = { version = "3", features = ["derive"] }
+
+[build-dependencies]
+capnpc = "0.14"
+\ No newline at end of file
diff --git a/build.rs b/build.rs
@@ -0,0 +1,10 @@
+fn main() {
+ capnpc::CompilerCommand::new()
+ .src_prefix("schema")
+ .import_path("schema")
+ .file("schema/utils.capnp")
+ .file("schema/events.capnp")
+ .file("schema/matrix.capnp")
+ .run()
+ .expect("schema compiler command");
+}
diff --git a/schema/events.capnp b/schema/events.capnp
@@ -0,0 +1,109 @@
+@0x9e7f64b0577ea649;
+
+using Util = import "/utils.capnp";
+
+struct MessageContent {
+ union {
+ text: group {
+ body @0: Text;
+ format @1: Util.Option(Text);
+ formattedBody @2: Util.Option(Text);
+ }
+ emote: group {
+ body @3: Text;
+ format @4: Util.Option(Text);
+ formattedBody @5: Util.Option(Text);
+ }
+ notice: group {
+ body @6: Text;
+ format @7: Util.Option(Text);
+ formattedBody @8: Util.Option(Text);
+ }
+ audio: group {
+ body @9: Text;
+ info @10: AudioInfo;
+ url @11: Text;
+ }
+ file: group {
+ body @12: Text;
+ filename @13: Text;
+ info @14: FileInfo;
+ url @15: Text;
+ }
+ image: group {
+ body @16: Text;
+ info @17: ImageInfo;
+ file @18: Util.Option(Text);
+ url @19: Text;
+ }
+ location: group {
+ body @20: Text;
+ geoUri @21: Text;
+ info @22: Util.Option(LocationInfo);
+ }
+ video: group {
+ body @23: Text;
+ info @24: VideoInfo;
+ url @25: Text;
+ }
+ serverNotice : group {
+ adminContact @26: Text;
+ body @27: VideoInfo;
+ limitType @28: LimitType;
+ serverNoticeType @29: ServerNoticeType;
+ }
+ }
+
+ enum ServerNoticeType {
+ usageLimitExceeded @0;
+ }
+
+ enum LimitType {
+ montlyActiveUser @0;
+ }
+
+ struct AudioInfo {
+ duration @0: UInt64;
+ mimeType @1: Text;
+ size @2: UInt64;
+ }
+
+ struct FileInfo {
+ mimeType @0: Text;
+ size @1: UInt64;
+ }
+
+ struct ImageInfo {
+ mimeType @0: Text;
+ size @1: UInt64;
+ h @2: UInt64;
+ w @3: UInt64;
+ }
+
+ struct LocationInfo {
+ thumbnailInfo @0: ImageInfo;
+ thumbnailUrl @1: Text;
+ thumbnailFile @2: Util.Option(Text);
+ }
+
+ struct VideoInfo {
+ duration @0: UInt64;
+ h @1: UInt64;
+ w @2: UInt64;
+ size @3: UInt64;
+ mimeType @4: Text;
+ thumbnailInfo @5: ImageInfo;
+ thumbnailUrl @6: Text;
+ }
+}
+
+enum MsgType {
+ text @0;
+ emote @1;
+ notice @2;
+ audio @3;
+ file @4;
+ image @5;
+ location @6;
+ video @7;
+}
+\ No newline at end of file
diff --git a/schema/matrix.capnp b/schema/matrix.capnp
@@ -0,0 +1,21 @@
+@0xeab570afa44bcb9d;
+
+using Util = import "/utils.capnp";
+using Events = import "/events.capnp";
+
+struct MessageEvent {
+ content @0: Events.MessageContent;
+ roomId @1: Text;
+ stateKey @2: Util.Option(Text);
+ sender @3: Text;
+ eventId @4: Text;
+ originServerTs @5: UInt64;
+ unsigned @6: Unsigned;
+}
+
+struct Unsigned(Content) {
+ age @0: UInt64;
+ transactionId @1: Text;
+ prevContent @2: Util.Option(Content);
+ redactedBecause @3: Util.Option(Text);
+}
+\ No newline at end of file
diff --git a/schema/utils.capnp b/schema/utils.capnp
@@ -0,0 +1,9 @@
+@0x9acbae5536535c84;
+
+# Equivalent to Rust's Option enum
+struct Option(SomeType) {
+ union {
+ none @0: Void;
+ some @1: SomeType;
+ }
+}
+\ No newline at end of file
diff --git a/src/main.rs b/src/main.rs
@@ -0,0 +1,101 @@
+use crate::events_capnp::message_content;
+use crate::matrix_capnp::message_event;
+use crate::utils_capnp::option;
+use capnp::serialize_packed;
+use clap::Parser;
+use color_eyre::eyre::{eyre, Result};
+use std::{fs::File, io::BufReader};
+
+pub mod matrix_capnp {
+ include!(concat!(env!("OUT_DIR"), "/matrix_capnp.rs"));
+}
+pub mod events_capnp {
+ include!(concat!(env!("OUT_DIR"), "/events_capnp.rs"));
+}
+pub mod utils_capnp {
+ include!(concat!(env!("OUT_DIR"), "/utils_capnp.rs"));
+}
+
+pub mod matrix {
+ use crate::matrix_capnp::message_event;
+ use capnp::message::{Builder, HeapAllocator};
+
+ pub fn build_event() -> Builder<HeapAllocator> {
+ let mut message = Builder::new_default();
+ {
+ let mut event = message.init_root::<message_event::Builder>();
+
+ {
+ event.set_event_id("$ip5l5n9ckymoybrwh-jl8BDYl8HCv2nO1d4NCFp4ek0");
+ event.set_origin_server_ts(1650133746117);
+ event.set_sender("@mtrnord:nordgedanken.dev");
+ event.set_room_id("!KwXDovBFhYakswlOwN:nordgedanken.dev");
+ let mut unsigned = event.reborrow().init_unsigned();
+ unsigned.set_age(405);
+ unsigned.set_transaction_id("m1650132888916.13");
+ let mut content = event.reborrow().init_content();
+ let mut text = content.reborrow().init_text();
+ text.set_body("This is a test");
+ let mut formatted_body = text.init_formatted_body();
+ formatted_body.set_none(());
+ }
+ }
+
+ message
+ }
+}
+
+#[derive(Parser, Debug)]
+#[clap(author, version, about, long_about = None)]
+struct Args {
+ #[clap(short, long)]
+ write: bool,
+ #[clap(short, long)]
+ read: bool,
+}
+
+fn main() -> Result<()> {
+ color_eyre::install()?;
+ let args = Args::parse();
+
+ if args.read && args.write || !args.read && !args.write {
+ return Err(eyre!("Either read or write must be specified"));
+ }
+
+ if args.read {
+ let mut data_file = File::open("./data")?;
+ let mut buf_reader = BufReader::new(&mut data_file);
+ let message_reader = serialize_packed::read_message(
+ &mut buf_reader,
+ ::capnp::message::ReaderOptions::new(),
+ )?;
+
+ let event = message_reader.get_root::<message_event::Reader>()?;
+
+ println!("event_id: {}", event.get_event_id()?);
+ println!("origin_server_ts: {}", event.get_origin_server_ts());
+ match event.get_content()?.which() {
+ Ok(message_content::Text(content)) => {
+ println!("text body: {}", content.get_body()?);
+ match content.get_formatted_body()?.which() {
+ Ok(option::Some(content)) => {
+ println!("text formatted_body: {}", content?)
+ }
+ Ok(option::None(())) => println!("emote formatted_body: None"),
+ Err(err) => println!("emote formatted_body: {:?}", err),
+ }
+ }
+ Err(err) => println!("content: {:?}", err),
+ _ => println!("content type not yet supported"),
+ }
+ } else if args.write {
+ let event = matrix::build_event();
+ let mut data_file = File::create("./data")?;
+
+ serialize_packed::write_message(&mut data_file, &event)?;
+
+ println!("Wrote event to ./data");
+ }
+
+ Ok(())
+}