From dd2e0afd47fb6380be062d00faac9e68d1ff6bca Mon Sep 17 00:00:00 2001 From: Jimmy Cuadra Date: Thu, 13 Jun 2019 17:13:24 -0700 Subject: [PATCH] All fields on FileInfo, ImageInfo, and ThumbnailInfo are optional. --- src/room.rs | 28 ++++++++++++++++++---------- src/room/message.rs | 4 ++-- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/room.rs b/src/room.rs index 9eb8c80e..68f03304 100644 --- a/src/room.rs +++ b/src/room.rs @@ -29,11 +29,18 @@ pub mod topic; pub struct ImageInfo { /// The height of the image in pixels. #[serde(rename = "h")] - pub height: u64, + #[serde(skip_serializing_if = "Option::is_none")] + pub height: Option, + /// The width of the image in pixels. + #[serde(rename = "w")] + #[serde(skip_serializing_if = "Option::is_none")] + pub width: Option, /// The MIME type of the image, e.g. "image/png." - pub mimetype: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub mimetype: Option, /// The file size of the image in bytes. - pub size: u64, + #[serde(skip_serializing_if = "Option::is_none")] + pub size: Option, /// Metadata about the image referred to in `thumbnail_url`. #[serde(skip_serializing_if = "Option::is_none")] pub thumbnail_info: Option, @@ -43,9 +50,6 @@ pub struct ImageInfo { /// Information on the encrypted thumbnail image. Only present if the thumbnail is encrypted. #[serde(skip_serializing_if = "Option::is_none")] pub thumbnail_file: Option, - /// The width of the image in pixels. - #[serde(rename = "w")] - pub width: u64, } /// Metadata about a thumbnail. @@ -53,14 +57,18 @@ pub struct ImageInfo { pub struct ThumbnailInfo { /// The height of the thumbnail in pixels. #[serde(rename = "h")] - pub height: u64, + #[serde(skip_serializing_if = "Option::is_none")] + pub height: Option, /// The MIME type of the thumbnail, e.g. "image/png." - pub mimetype: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub mimetype: Option, /// The file size of the thumbnail in bytes. - pub size: u64, + #[serde(skip_serializing_if = "Option::is_none")] + pub size: Option, /// The width of the thumbnail in pixels. #[serde(rename = "w")] - pub width: u64, + #[serde(skip_serializing_if = "Option::is_none")] + pub width: Option, } /// A file sent to a room with end-to-end encryption enabled. diff --git a/src/room/message.rs b/src/room/message.rs index 1346dbb7..b0ac710d 100644 --- a/src/room/message.rs +++ b/src/room/message.rs @@ -161,9 +161,9 @@ pub struct FileMessageEventContent { #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct FileInfo { /// The mimetype of the file, e.g. "application/msword." - pub mimetype: String, + pub mimetype: Option, /// The size of the file in bytes. - pub size: u64, + pub size: Option, /// Metadata about the image referred to in `thumbnail_url`. #[serde(skip_serializing_if = "Option::is_none")] pub thumbnail_info: Option,