Skip serializing option values that are none.
This commit is contained in:
		
							parent
							
								
									ca4c8a6784
								
							
						
					
					
						commit
						f35f2015eb
					
				@ -116,6 +116,7 @@ pub struct RoomEvent<C, E> where C: Deserialize + Serialize, E: Deserialize + Se
 | 
				
			|||||||
    pub room_id: RoomId,
 | 
					    pub room_id: RoomId,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Additional key-value pairs not signed by the homeserver.
 | 
					    /// Additional key-value pairs not signed by the homeserver.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub unsigned: Option<Value>,
 | 
					    pub unsigned: Option<Value>,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// The unique identifier for the user associated with this event.
 | 
					    /// The unique identifier for the user associated with this event.
 | 
				
			||||||
@ -141,6 +142,7 @@ pub struct StateEvent<C, E> where C: Deserialize + Serialize, E: Deserialize + S
 | 
				
			|||||||
    pub extra_content: E,
 | 
					    pub extra_content: E,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// The previous content for this state key, if any.
 | 
					    /// The previous content for this state key, if any.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub prev_content: Option<C>,
 | 
					    pub prev_content: Option<C>,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// The unique identifier for the room associated with this event.
 | 
					    /// The unique identifier for the room associated with this event.
 | 
				
			||||||
@ -150,6 +152,7 @@ pub struct StateEvent<C, E> where C: Deserialize + Serialize, E: Deserialize + S
 | 
				
			|||||||
    pub state_key: String,
 | 
					    pub state_key: String,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Additional key-value pairs not signed by the homeserver.
 | 
					    /// Additional key-value pairs not signed by the homeserver.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub unsigned: Option<Value>,
 | 
					    pub unsigned: Option<Value>,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// The unique identifier for the user associated with this event.
 | 
					    /// The unique identifier for the user associated with this event.
 | 
				
			||||||
 | 
				
			|||||||
@ -11,15 +11,18 @@ pub type PresenceEvent = Event<PresenceEventContent, PresenceEventExtraContent>;
 | 
				
			|||||||
#[derive(Debug, Deserialize, Serialize)]
 | 
					#[derive(Debug, Deserialize, Serialize)]
 | 
				
			||||||
pub struct PresenceEventContent {
 | 
					pub struct PresenceEventContent {
 | 
				
			||||||
    /// The current avatar URL for this user.
 | 
					    /// The current avatar URL for this user.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub avatar_url: Option<String>,
 | 
					    pub avatar_url: Option<String>,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Whether or not the user is currently active.
 | 
					    /// Whether or not the user is currently active.
 | 
				
			||||||
    pub currently_active: bool,
 | 
					    pub currently_active: bool,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// The current display name for this user.
 | 
					    /// The current display name for this user.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub displayname: Option<String>,
 | 
					    pub displayname: Option<String>,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// The last time since this used performed some action, in milliseconds.
 | 
					    /// The last time since this used performed some action, in milliseconds.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub last_active_ago: Option<u64>,
 | 
					    pub last_active_ago: Option<u64>,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// The presence state for this user.
 | 
					    /// The presence state for this user.
 | 
				
			||||||
 | 
				
			|||||||
@ -22,9 +22,11 @@ pub type MemberEvent = StateEvent<MemberEventContent, MemberEventExtraContent>;
 | 
				
			|||||||
#[derive(Debug, Deserialize, Serialize)]
 | 
					#[derive(Debug, Deserialize, Serialize)]
 | 
				
			||||||
pub struct MemberEventContent {
 | 
					pub struct MemberEventContent {
 | 
				
			||||||
    /// The avatar URL for this user.
 | 
					    /// The avatar URL for this user.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub avatar_url: Option<String>,
 | 
					    pub avatar_url: Option<String>,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// The display name for this user.
 | 
					    /// The display name for this user.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub displayname: Option<String>,
 | 
					    pub displayname: Option<String>,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// The membership state of this user.
 | 
					    /// The membership state of this user.
 | 
				
			||||||
@ -57,6 +59,7 @@ pub enum MembershipState {
 | 
				
			|||||||
#[derive(Debug, Deserialize, Serialize)]
 | 
					#[derive(Debug, Deserialize, Serialize)]
 | 
				
			||||||
pub struct MemberEventExtraContent {
 | 
					pub struct MemberEventExtraContent {
 | 
				
			||||||
    /// A subset of the state of the room at the time of the invite.
 | 
					    /// A subset of the state of the room at the time of the invite.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub invite_room_state: Option<Vec<StrippedState>>,
 | 
					    pub invite_room_state: Option<Vec<StrippedState>>,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -68,6 +68,7 @@ pub struct AudioMessageEventContent {
 | 
				
			|||||||
    /// The textual representation of this message.
 | 
					    /// The textual representation of this message.
 | 
				
			||||||
    pub body: String,
 | 
					    pub body: String,
 | 
				
			||||||
    /// Metadata for the audio clip referred to in `url`.
 | 
					    /// Metadata for the audio clip referred to in `url`.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub info: Option<AudioInfo>,
 | 
					    pub info: Option<AudioInfo>,
 | 
				
			||||||
    /// The message type. Always *m.audio*.
 | 
					    /// The message type. Always *m.audio*.
 | 
				
			||||||
    pub msgtype: MessageType,
 | 
					    pub msgtype: MessageType,
 | 
				
			||||||
@ -79,10 +80,13 @@ pub struct AudioMessageEventContent {
 | 
				
			|||||||
#[derive(Debug, Deserialize, Serialize)]
 | 
					#[derive(Debug, Deserialize, Serialize)]
 | 
				
			||||||
pub struct AudioInfo {
 | 
					pub struct AudioInfo {
 | 
				
			||||||
    /// The duration of the audio in milliseconds.
 | 
					    /// The duration of the audio in milliseconds.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub duration: Option<u64>,
 | 
					    pub duration: Option<u64>,
 | 
				
			||||||
    /// The mimetype of the audio, e.g. "audio/aac."
 | 
					    /// The mimetype of the audio, e.g. "audio/aac."
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub mimetype: Option<String>,
 | 
					    pub mimetype: Option<String>,
 | 
				
			||||||
    /// The size of the audio clip in bytes.
 | 
					    /// The size of the audio clip in bytes.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub size: Option<u64>,
 | 
					    pub size: Option<u64>,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -102,12 +106,15 @@ pub struct FileMessageEventContent {
 | 
				
			|||||||
    /// original upload.
 | 
					    /// original upload.
 | 
				
			||||||
    pub body: String,
 | 
					    pub body: String,
 | 
				
			||||||
    /// Metadata about the file referred to in `url`.
 | 
					    /// Metadata about the file referred to in `url`.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub info: Option<FileInfo>,
 | 
					    pub info: Option<FileInfo>,
 | 
				
			||||||
    /// The message type. Always *m.file*.
 | 
					    /// The message type. Always *m.file*.
 | 
				
			||||||
    pub msgtype: MessageType,
 | 
					    pub msgtype: MessageType,
 | 
				
			||||||
    /// Metadata about the image referred to in `thumbnail_url`.
 | 
					    /// Metadata about the image referred to in `thumbnail_url`.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub thumbnail_info: Option<ImageInfo>,
 | 
					    pub thumbnail_info: Option<ImageInfo>,
 | 
				
			||||||
    /// The URL to the thumbnail of the file.
 | 
					    /// The URL to the thumbnail of the file.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub thumbnail_url: Option<String>,
 | 
					    pub thumbnail_url: Option<String>,
 | 
				
			||||||
    /// The URL to the file.
 | 
					    /// The URL to the file.
 | 
				
			||||||
    pub url: String,
 | 
					    pub url: String,
 | 
				
			||||||
@ -129,12 +136,15 @@ pub struct ImageMessageEventContent {
 | 
				
			|||||||
    /// of the image, or some kind of content description for accessibility e.g. "image attachment."
 | 
					    /// of the image, or some kind of content description for accessibility e.g. "image attachment."
 | 
				
			||||||
    pub body: String,
 | 
					    pub body: String,
 | 
				
			||||||
    /// Metadata about the image referred to in `url`.
 | 
					    /// Metadata about the image referred to in `url`.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub info: Option<ImageInfo>,
 | 
					    pub info: Option<ImageInfo>,
 | 
				
			||||||
    /// The message type. Always *m.image*.
 | 
					    /// The message type. Always *m.image*.
 | 
				
			||||||
    pub msgtype: MessageType,
 | 
					    pub msgtype: MessageType,
 | 
				
			||||||
    /// Metadata about the image referred to in `thumbnail_url`.
 | 
					    /// Metadata about the image referred to in `thumbnail_url`.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub thumbnail_info: Option<ImageInfo>,
 | 
					    pub thumbnail_info: Option<ImageInfo>,
 | 
				
			||||||
    /// The URL to the thumbnail of the image.
 | 
					    /// The URL to the thumbnail of the image.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub thumbnail_url: Option<String>,
 | 
					    pub thumbnail_url: Option<String>,
 | 
				
			||||||
    /// The URL to the image.
 | 
					    /// The URL to the image.
 | 
				
			||||||
    pub url: String,
 | 
					    pub url: String,
 | 
				
			||||||
@ -151,8 +161,10 @@ pub struct LocationMessageEventContent {
 | 
				
			|||||||
    /// The message type. Always *m.location*.
 | 
					    /// The message type. Always *m.location*.
 | 
				
			||||||
    pub msgtype: MessageType,
 | 
					    pub msgtype: MessageType,
 | 
				
			||||||
    /// Metadata about the image referred to in `thumbnail_url`.
 | 
					    /// Metadata about the image referred to in `thumbnail_url`.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub thumbnail_info: Option<ImageInfo>,
 | 
					    pub thumbnail_info: Option<ImageInfo>,
 | 
				
			||||||
    /// The URL to a thumbnail of the location being represented.
 | 
					    /// The URL to a thumbnail of the location being represented.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub thumbnail_url: Option<String>,
 | 
					    pub thumbnail_url: Option<String>,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -181,6 +193,7 @@ pub struct VideoMessageEventContent {
 | 
				
			|||||||
    /// accessibility, e.g. "video attachment."
 | 
					    /// accessibility, e.g. "video attachment."
 | 
				
			||||||
    pub body: String,
 | 
					    pub body: String,
 | 
				
			||||||
    /// Metadata about the video clip referred to in `url`.
 | 
					    /// Metadata about the video clip referred to in `url`.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub info: Option<VideoInfo>,
 | 
					    pub info: Option<VideoInfo>,
 | 
				
			||||||
    /// The message type. Always *m.video*.
 | 
					    /// The message type. Always *m.video*.
 | 
				
			||||||
    pub msgtype: MessageType,
 | 
					    pub msgtype: MessageType,
 | 
				
			||||||
@ -192,18 +205,25 @@ pub struct VideoMessageEventContent {
 | 
				
			|||||||
#[derive(Debug, Deserialize, Serialize)]
 | 
					#[derive(Debug, Deserialize, Serialize)]
 | 
				
			||||||
pub struct VideoInfo {
 | 
					pub struct VideoInfo {
 | 
				
			||||||
    /// The duration of the video in milliseconds.
 | 
					    /// The duration of the video in milliseconds.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub duration: Option<u64>,
 | 
					    pub duration: Option<u64>,
 | 
				
			||||||
    /// The height of the video in pixels.
 | 
					    /// The height of the video in pixels.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub h: Option<u64>,
 | 
					    pub h: Option<u64>,
 | 
				
			||||||
    /// The mimetype of the video, e.g. "video/mp4."
 | 
					    /// The mimetype of the video, e.g. "video/mp4."
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub mimetype: Option<String>,
 | 
					    pub mimetype: Option<String>,
 | 
				
			||||||
    /// The size of the video in bytes.
 | 
					    /// The size of the video in bytes.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub size: Option<u64>,
 | 
					    pub size: Option<u64>,
 | 
				
			||||||
    /// Metadata about an image.
 | 
					    /// Metadata about an image.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub thumbnail_info: Option<ImageInfo>,
 | 
					    pub thumbnail_info: Option<ImageInfo>,
 | 
				
			||||||
    /// The URL to a thumbnail of the video clip.
 | 
					    /// The URL to a thumbnail of the video clip.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub thumbnail_url: Option<String>,
 | 
					    pub thumbnail_url: Option<String>,
 | 
				
			||||||
    /// The width of the video in pixels.
 | 
					    /// The width of the video in pixels.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub w: Option<u64>,
 | 
					    pub w: Option<u64>,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -11,6 +11,7 @@ pub type RedactionEvent = RoomEvent<RedactionEventContent, RedactionEventExtraCo
 | 
				
			|||||||
#[derive(Debug, Deserialize, Serialize)]
 | 
					#[derive(Debug, Deserialize, Serialize)]
 | 
				
			||||||
pub struct RedactionEventContent {
 | 
					pub struct RedactionEventContent {
 | 
				
			||||||
    /// The reason for the redaction, if any.
 | 
					    /// The reason for the redaction, if any.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub reason: Option<String>,
 | 
					    pub reason: Option<String>,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -22,6 +22,7 @@ pub struct ThirdPartyInviteEventContent {
 | 
				
			|||||||
    pub public_key: String,
 | 
					    pub public_key: String,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Keys with which the token may be signed.
 | 
					    /// Keys with which the token may be signed.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub public_keys: Option<Vec<PublicKey>>,
 | 
					    pub public_keys: Option<Vec<PublicKey>>,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -32,6 +33,7 @@ pub struct PublicKey {
 | 
				
			|||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// The URL must return a JSON object containing a boolean property named 'valid'.
 | 
					    /// The URL must return a JSON object containing a boolean property named 'valid'.
 | 
				
			||||||
    /// If this URL is absent, the key must be considered valid indefinitely.
 | 
					    /// If this URL is absent, the key must be considered valid indefinitely.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub key_validity_url: Option<String>,
 | 
					    pub key_validity_url: Option<String>,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// A Base64-encoded Ed25519 key with which the token must be signed.
 | 
					    /// A Base64-encoded Ed25519 key with which the token must be signed.
 | 
				
			||||||
 | 
				
			|||||||
@ -18,5 +18,6 @@ pub struct TagEventContent {
 | 
				
			|||||||
#[derive(Debug, Deserialize, Serialize)]
 | 
					#[derive(Debug, Deserialize, Serialize)]
 | 
				
			||||||
pub struct TagInfo {
 | 
					pub struct TagInfo {
 | 
				
			||||||
    /// Value to use for lexicographically ordering rooms with this tag.
 | 
					    /// Value to use for lexicographically ordering rooms with this tag.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if="Option::is_none")]
 | 
				
			||||||
    pub order: Option<u64>,
 | 
					    pub order: Option<u64>,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user