events: Add builder-style methods to media event content structs
This commit is contained in:
parent
c1fa8d9406
commit
b183677ef5
@ -42,6 +42,15 @@ impl AudioMessageEventContent {
|
|||||||
pub fn encrypted(body: String, file: EncryptedFile) -> Self {
|
pub fn encrypted(body: String, file: EncryptedFile) -> Self {
|
||||||
Self::new(body, MediaSource::Encrypted(Box::new(file)))
|
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<Option<Box<AudioInfo>>>) -> Self {
|
||||||
|
Self { info: info.into(), ..self }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Metadata about an audio clip.
|
/// Metadata about an audio clip.
|
||||||
|
@ -46,6 +46,24 @@ impl FileMessageEventContent {
|
|||||||
pub fn encrypted(body: String, file: EncryptedFile) -> Self {
|
pub fn encrypted(body: String, file: EncryptedFile) -> Self {
|
||||||
Self::new(body, MediaSource::Encrypted(Box::new(file)))
|
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<Option<String>>) -> 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<Option<Box<FileInfo>>>) -> Self {
|
||||||
|
Self { info: info.into(), ..self }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Metadata about a file.
|
/// Metadata about a file.
|
||||||
|
@ -41,4 +41,13 @@ impl ImageMessageEventContent {
|
|||||||
pub fn encrypted(body: String, file: EncryptedFile) -> Self {
|
pub fn encrypted(body: String, file: EncryptedFile) -> Self {
|
||||||
Self::new(body, MediaSource::Encrypted(Box::new(file)))
|
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<Option<Box<ImageInfo>>>) -> Self {
|
||||||
|
Self { info: info.into(), ..self }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,15 @@ impl VideoMessageEventContent {
|
|||||||
pub fn encrypted(body: String, file: EncryptedFile) -> Self {
|
pub fn encrypted(body: String, file: EncryptedFile) -> Self {
|
||||||
Self::new(body, MediaSource::Encrypted(Box::new(file)))
|
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<Option<Box<VideoInfo>>>) -> Self {
|
||||||
|
Self { info: info.into(), ..self }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Metadata about a video.
|
/// Metadata about a video.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user