Merge remote-tracking branch 'upstream/main' into conduwuit-changes

This commit is contained in:
strawberry 2024-03-12 22:22:00 -04:00
commit 35a6a83721
4 changed files with 13 additions and 77 deletions

View File

@ -18,7 +18,9 @@ pub struct AudioMessageEventContent {
/// uploaded file. Otherwise, this should be interpreted as a user-written media caption.
pub body: String,
/// Formatted form of the message `body`, if `body` is a caption.
/// Formatted form of the message `body`.
///
/// This should only be set if the body represents a caption.
#[serde(flatten)]
pub formatted: Option<FormattedBody>,
@ -67,7 +69,7 @@ impl AudioMessageEventContent {
}
}
/// Creates a new non-encrypted `AudioMessageEventContent` with the given bod and url.
/// Creates a new non-encrypted `AudioMessageEventContent` with the given body and url.
pub fn plain(body: String, url: OwnedMxcUri) -> Self {
Self::new(body, MediaSource::Plain(url))
}
@ -78,24 +80,6 @@ impl AudioMessageEventContent {
Self::new(body, MediaSource::Encrypted(Box::new(file)))
}
/// Creates a new `AudioMessageEventContent` 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 `AudioMessageEventContent` from `self` with the `formatted` 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 formatted(self, formatted: impl Into<Option<FormattedBody>>) -> Self {
Self { formatted: formatted.into(), ..self }
}
/// Creates a new `AudioMessageEventContent` from `self` with the `info` field set to the given
/// value.
///

View File

@ -16,7 +16,9 @@ pub struct FileMessageEventContent {
/// uploaded file. Otherwise, this should be interpreted as a user-written media caption.
pub body: String,
/// Formatted form of the message `body`, if `body` is a caption.
/// Formatted form of the message `body`.
///
/// This should only be set if the body represents a caption.
#[serde(flatten)]
pub formatted: Option<FormattedBody>,
@ -50,24 +52,6 @@ impl FileMessageEventContent {
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 `formatted` 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 formatted(self, formatted: impl Into<Option<FormattedBody>>) -> Self {
Self { formatted: formatted.into(), ..self }
}
/// Creates a new `FileMessageEventContent` from `self` with the `info` field set to the given
/// value.
///

View File

@ -15,7 +15,9 @@ pub struct ImageMessageEventContent {
/// uploaded file. Otherwise, this should be interpreted as a user-written media caption.
pub body: String,
/// Formatted form of the message `body`, if `body` is a caption.
/// Formatted form of the message `body`.
///
/// This should only be set if the body represents a caption.
#[serde(flatten)]
pub formatted: Option<FormattedBody>,
@ -49,24 +51,6 @@ impl ImageMessageEventContent {
Self::new(body, MediaSource::Encrypted(Box::new(file)))
}
/// Creates a new `ImageMessageEventContent` 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 `ImageMessageEventContent` from `self` with the `formatted` 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 formatted(self, formatted: impl Into<Option<FormattedBody>>) -> Self {
Self { formatted: formatted.into(), ..self }
}
/// Creates a new `ImageMessageEventContent` from `self` with the `info` field set to the given
/// value.
///

View File

@ -18,7 +18,9 @@ pub struct VideoMessageEventContent {
/// uploaded file. Otherwise, this should be interpreted as a user-written media caption.
pub body: String,
/// Formatted form of the message `body`, if `body` is a caption.
/// Formatted form of the message `body`.
///
/// This should only be set if the body represents a caption.
#[serde(flatten)]
pub formatted: Option<FormattedBody>,
@ -52,24 +54,6 @@ impl VideoMessageEventContent {
Self::new(body, MediaSource::Encrypted(Box::new(file)))
}
/// Creates a new `VideoMessageEventContent` 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 `VideoMessageEventContent` from `self` with the `formatted` 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 formatted(self, formatted: impl Into<Option<FormattedBody>>) -> Self {
Self { formatted: formatted.into(), ..self }
}
/// Creates a new `VideoMessageEventContent` from `self` with the `info` field set to the given
/// value.
///