diff --git a/crates/ruma-common/src/events/room/message/audio.rs b/crates/ruma-common/src/events/room/message/audio.rs
index 7f187304..a1edb684 100644
--- a/crates/ruma-common/src/events/room/message/audio.rs
+++ b/crates/ruma-common/src/events/room/message/audio.rs
@@ -42,6 +42,15 @@ impl AudioMessageEventContent {
pub fn encrypted(body: String, file: EncryptedFile) -> Self {
Self::new(body, MediaSource::Encrypted(Box::new(file)))
}
+
+ /// Creates a new `AudioMessageEventContent` from `self` with the `info` field set to the given
+ /// value.
+ ///
+ /// Since the field is public, you can also assign to it directly. This method merely acts
+ /// as a shorthand for that, because it is very common to set this field.
+ pub fn info(self, info: impl Into>>) -> Self {
+ Self { info: info.into(), ..self }
+ }
}
/// Metadata about an audio clip.
diff --git a/crates/ruma-common/src/events/room/message/file.rs b/crates/ruma-common/src/events/room/message/file.rs
index 60be19fb..f85226a6 100644
--- a/crates/ruma-common/src/events/room/message/file.rs
+++ b/crates/ruma-common/src/events/room/message/file.rs
@@ -46,6 +46,24 @@ impl FileMessageEventContent {
pub fn encrypted(body: String, file: EncryptedFile) -> Self {
Self::new(body, MediaSource::Encrypted(Box::new(file)))
}
+
+ /// Creates a new `FileMessageEventContent` from `self` with the `filename` field set to the
+ /// given value.
+ ///
+ /// Since the field is public, you can also assign to it directly. This method merely acts
+ /// as a shorthand for that, because it is very common to set this field.
+ pub fn filename(self, filename: impl Into >) -> Self {
+ Self { filename: filename.into(), ..self }
+ }
+
+ /// Creates a new `FileMessageEventContent` from `self` with the `info` field set to the given
+ /// value.
+ ///
+ /// Since the field is public, you can also assign to it directly. This method merely acts
+ /// as a shorthand for that, because it is very common to set this field.
+ pub fn info(self, info: impl Into >>) -> Self {
+ Self { info: info.into(), ..self }
+ }
}
/// Metadata about a file.
diff --git a/crates/ruma-common/src/events/room/message/image.rs b/crates/ruma-common/src/events/room/message/image.rs
index ef049a14..cbf7548a 100644
--- a/crates/ruma-common/src/events/room/message/image.rs
+++ b/crates/ruma-common/src/events/room/message/image.rs
@@ -41,4 +41,13 @@ impl ImageMessageEventContent {
pub fn encrypted(body: String, file: EncryptedFile) -> Self {
Self::new(body, MediaSource::Encrypted(Box::new(file)))
}
+
+ /// Creates a new `ImageMessageEventContent` from `self` with the `info` field set to the given
+ /// value.
+ ///
+ /// Since the field is public, you can also assign to it directly. This method merely acts
+ /// as a shorthand for that, because it is very common to set this field.
+ pub fn info(self, info: impl Into >>) -> Self {
+ Self { info: info.into(), ..self }
+ }
}
diff --git a/crates/ruma-common/src/events/room/message/video.rs b/crates/ruma-common/src/events/room/message/video.rs
index 32d68fc9..3c945c0e 100644
--- a/crates/ruma-common/src/events/room/message/video.rs
+++ b/crates/ruma-common/src/events/room/message/video.rs
@@ -43,6 +43,15 @@ impl VideoMessageEventContent {
pub fn encrypted(body: String, file: EncryptedFile) -> Self {
Self::new(body, MediaSource::Encrypted(Box::new(file)))
}
+
+ /// Creates a new `VideoMessageEventContent` from `self` with the `info` field set to the given
+ /// value.
+ ///
+ /// Since the field is public, you can also assign to it directly. This method merely acts
+ /// as a shorthand for that, because it is very common to set this field.
+ pub fn info(self, info: impl Into >>) -> Self {
+ Self { info: info.into(), ..self }
+ }
}
/// Metadata about a video.