Skip to content

Commit

Permalink
doc(base): Add missing documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hywan committed Jul 10, 2024
1 parent bf40bf8 commit c7979cb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
24 changes: 24 additions & 0 deletions crates/matrix-sdk-base/src/sliding_sync/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,21 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//! HTTP types for (Simplified) MSC3575.
//!
//! This module provides a unified namings for types from MSC3575 and
//! Simplified MSC3575, in addition to provide conversion from one
//! format to another.
use std::collections::BTreeMap;

/// Same trait as [`std::convert::From`].
///
/// Because we are converting types that all live in another
// crate (`ruma`), we cannot implement `From` on them, so we
// need a custom local trait, hence this `From` trait.
pub trait From<T>: Sized {
/// See [`std::convert::From::from`].
fn from(value: T) -> Self;
}

Expand Down Expand Up @@ -46,7 +58,13 @@ where
}
}

/// Same trait as [`std::convert::Into`].
///
/// Because we are converting types that all live in another
// crate (`ruma`), we cannot implement `Into` on them, so we
// need a custom local trait, hence this `Into` trait.
pub trait Into<T>: Sized {
/// See [`std::convert::Into::into`].
#[must_use]
fn into(self) -> T;
}
Expand All @@ -62,6 +80,7 @@ where
}
}

/// HTTP types from MSC3575, renamed to match the Simplified MSC3575 namings.
pub mod msc3575 {
use super::{simplified_msc3575 as sss, From};
use ruma::{api::client::sync::sync_events::v4, events::TimelineEventType};
Expand All @@ -79,6 +98,8 @@ pub mod msc3575 {
SlidingSyncRoomHero as ResponseRoomHero, SyncList as ResponseList,
};

/// HTTP types for MSC3575 extensions, renamed to match the Simplified
/// MSC3575 namings.
pub mod extensions {
// Request types.
pub use super::v4::{
Expand Down Expand Up @@ -118,6 +139,8 @@ pub mod msc3575 {
s.room_details = From::from(value.room_details);
s.include_heroes = value.include_heroes;
s.filters = From::from(value.filters);

// Defaults from Simplified MSC3575.
s.sort = vec!["by_recency".to_string(), "by_name".to_string()];
s.bump_event_types = vec![
TimelineEventType::RoomMessage,
Expand Down Expand Up @@ -247,6 +270,7 @@ pub mod msc3575 {
}
}

/// HTTP types from Simplified MSC3575.
pub mod simplified_msc3575 {
use super::{msc3575 as ss, From};
pub use ruma::api::client::sync::sync_events::v5::*;
Expand Down
2 changes: 2 additions & 0 deletions crates/matrix-sdk-base/src/sliding_sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//! Extend `BaseClient` with capabilities to handle MSC3575.
pub mod http;

use std::collections::BTreeMap;
Expand Down

0 comments on commit c7979cb

Please sign in to comment.