events: Make extensible events conversion helpers private

This commit is contained in:
Kévin Commaille 2022-07-02 17:41:19 +02:00 committed by Kévin Commaille
parent bda17c3662
commit be2310294a
9 changed files with 17 additions and 14 deletions

View File

@ -165,7 +165,7 @@ impl FileContent {
} }
/// Create a new `FileContent` with the given media source, file info and filename. /// Create a new `FileContent` with the given media source, file info and filename.
pub fn from_room_message_content( pub(crate) fn from_room_message_content(
source: MediaSource, source: MediaSource,
filename: Option<String>, filename: Option<String>,
mimetype: Option<String>, mimetype: Option<String>,
@ -210,7 +210,7 @@ impl FileContentInfo {
/// Create a new `FileContentInfo` with the given filename, mimetype and size. /// Create a new `FileContentInfo` with the given filename, mimetype and size.
/// ///
/// Returns `None` if all parameters are `None`. /// Returns `None` if all parameters are `None`.
pub fn from_room_message_content( pub(crate) fn from_room_message_content(
filename: Option<String>, filename: Option<String>,
mimetype: Option<String>, mimetype: Option<String>,
size: Option<UInt>, size: Option<UInt>,

View File

@ -203,7 +203,7 @@ impl ThumbnailContent {
/// Create a `ThumbnailContent` with the given thumbnail source and info. /// Create a `ThumbnailContent` with the given thumbnail source and info.
/// ///
/// Returns `None` if no thumbnail was found. /// Returns `None` if no thumbnail was found.
pub fn from_room_message_content( pub(crate) fn from_room_message_content(
source: Option<MediaSource>, source: Option<MediaSource>,
info: Option<Box<ThumbnailInfo>>, info: Option<Box<ThumbnailInfo>>,
) -> Option<Self> { ) -> Option<Self> {

View File

@ -177,7 +177,10 @@ impl MessageContent {
} }
/// Create a new `MessageContent` from the given body and optional formatted body. /// Create a new `MessageContent` from the given body and optional formatted body.
pub fn from_room_message_content(body: String, formatted: Option<FormattedBody>) -> Self { pub(crate) fn from_room_message_content(
body: String,
formatted: Option<FormattedBody>,
) -> Self {
if let Some(FormattedBody { body: html_body, .. }) = if let Some(FormattedBody { body: html_body, .. }) =
formatted.filter(|formatted| formatted.format == MessageFormat::Html) formatted.filter(|formatted| formatted.format == MessageFormat::Html)
{ {

View File

@ -165,7 +165,7 @@ impl ImageInfo {
/// Create an `ImageInfo` from the given file info, image info and thumbnail. /// Create an `ImageInfo` from the given file info, image info and thumbnail.
#[cfg(feature = "unstable-msc3552")] #[cfg(feature = "unstable-msc3552")]
pub fn from_extensible_content( fn from_extensible_content(
file_info: Option<&FileContentInfo>, file_info: Option<&FileContentInfo>,
image: &ImageContent, image: &ImageContent,
thumbnail: &[ThumbnailContent], thumbnail: &[ThumbnailContent],
@ -235,7 +235,7 @@ impl ThumbnailInfo {
/// ///
/// Returns `None` if `file_info` and `image` are `None`. /// Returns `None` if `file_info` and `image` are `None`.
#[cfg(feature = "unstable-msc3552")] #[cfg(feature = "unstable-msc3552")]
pub fn from_extensible_content( fn from_extensible_content(
file_info: Option<&ThumbnailFileContentInfo>, file_info: Option<&ThumbnailFileContentInfo>,
image: Option<&ImageContent>, image: Option<&ImageContent>,
) -> Option<Self> { ) -> Option<Self> {
@ -280,7 +280,7 @@ pub struct EncryptedFile {
#[cfg(feature = "unstable-msc3551")] #[cfg(feature = "unstable-msc3551")]
impl EncryptedFile { impl EncryptedFile {
/// Create an `EncryptedFile` from the given url and encryption info. /// Create an `EncryptedFile` from the given url and encryption info.
pub fn from_extensible_content(url: &MxcUri, encryption_info: &EncryptedContent) -> Self { fn from_extensible_content(url: &MxcUri, encryption_info: &EncryptedContent) -> Self {
let EncryptedContent { key, iv, hashes, v } = encryption_info.to_owned(); let EncryptedContent { key, iv, hashes, v } = encryption_info.to_owned();
Self { url: url.to_owned(), key, iv, hashes, v } Self { url: url.to_owned(), key, iv, hashes, v }
} }

View File

@ -132,7 +132,7 @@ impl AudioMessageEventContent {
/// Create a new `AudioMessageEventContent` with the given message, file info and audio info. /// Create a new `AudioMessageEventContent` with the given message, file info and audio info.
#[cfg(feature = "unstable-msc3246")] #[cfg(feature = "unstable-msc3246")]
pub fn from_extensible_content( pub(crate) fn from_extensible_content(
message: MessageContent, message: MessageContent,
file: FileContent, file: FileContent,
audio: AudioContent, audio: AudioContent,
@ -203,7 +203,7 @@ impl AudioInfo {
/// ///
/// Returns `None` if the `AudioInfo` would be empty. /// Returns `None` if the `AudioInfo` would be empty.
#[cfg(feature = "unstable-msc3246")] #[cfg(feature = "unstable-msc3246")]
pub fn from_extensible_content( fn from_extensible_content(
file_info: Option<&FileContentInfo>, file_info: Option<&FileContentInfo>,
audio: &AudioContent, audio: &AudioContent,
) -> Option<Self> { ) -> Option<Self> {

View File

@ -101,7 +101,7 @@ impl FileMessageEventContent {
/// Create a new `FileMessageEventContent` with the given message and file info. /// Create a new `FileMessageEventContent` with the given message and file info.
#[cfg(feature = "unstable-msc3551")] #[cfg(feature = "unstable-msc3551")]
pub fn from_extensible_content(message: MessageContent, file: FileContent) -> Self { pub(crate) fn from_extensible_content(message: MessageContent, file: FileContent) -> Self {
let body = if let Some(body) = message.find_plain() { let body = if let Some(body) = message.find_plain() {
body.to_owned() body.to_owned()
} else { } else {

View File

@ -147,7 +147,7 @@ impl ImageMessageEventContent {
/// Create a new `ImageMessageEventContent` with the given message, file info, image info, /// Create a new `ImageMessageEventContent` with the given message, file info, image info,
/// thumbnails and captions. /// thumbnails and captions.
#[cfg(feature = "unstable-msc3552")] #[cfg(feature = "unstable-msc3552")]
pub fn from_extensible_content( pub(crate) fn from_extensible_content(
message: MessageContent, message: MessageContent,
file: FileContent, file: FileContent,
image: Box<ImageContent>, image: Box<ImageContent>,

View File

@ -82,7 +82,7 @@ impl LocationMessageEventContent {
/// Create a new `LocationMessageEventContent` with the given message, location info, asset and /// Create a new `LocationMessageEventContent` with the given message, location info, asset and
/// timestamp. /// timestamp.
#[cfg(feature = "unstable-msc3488")] #[cfg(feature = "unstable-msc3488")]
pub fn from_extensible_content( pub(crate) fn from_extensible_content(
message: MessageContent, message: MessageContent,
location: LocationContent, location: LocationContent,
asset: AssetContent, asset: AssetContent,

View File

@ -153,7 +153,7 @@ impl VideoMessageEventContent {
/// Create a new `VideoMessageEventContent` with the given message, file info, video info, /// Create a new `VideoMessageEventContent` with the given message, file info, video info,
/// thumbnails and captions. /// thumbnails and captions.
#[cfg(feature = "unstable-msc3553")] #[cfg(feature = "unstable-msc3553")]
pub fn from_extensible_content( pub(crate) fn from_extensible_content(
message: MessageContent, message: MessageContent,
file: FileContent, file: FileContent,
video: Box<VideoContent>, video: Box<VideoContent>,
@ -240,7 +240,7 @@ impl VideoInfo {
/// Create a `VideoInfo` from the given file info, video info and thumbnail. /// Create a `VideoInfo` from the given file info, video info and thumbnail.
#[cfg(feature = "unstable-msc3553")] #[cfg(feature = "unstable-msc3553")]
pub fn from_extensible_content( fn from_extensible_content(
file_info: Option<&FileContentInfo>, file_info: Option<&FileContentInfo>,
video: &VideoContent, video: &VideoContent,
thumbnail: &[ThumbnailContent], thumbnail: &[ThumbnailContent],