12
12
// See the License for the specific language governing permissions and
13
13
// limitations under the License.
14
14
15
+ //! HTTP types for (Simplified) MSC3575.
16
+ //!
17
+ //! This module provides a unified namings for types from MSC3575 and
18
+ //! Simplified MSC3575, in addition to provide conversion from one
19
+ //! format to another.
20
+
15
21
use std:: collections:: BTreeMap ;
16
22
23
+ /// Same trait as [`std::convert::From`].
24
+ ///
25
+ /// Because we are converting types that all live in another
26
+ // crate (`ruma`), we cannot implement `From` on them, so we
27
+ // need a custom local trait, hence this `From` trait.
17
28
pub trait From < T > : Sized {
29
+ /// See [`std::convert::From::from`].
18
30
fn from ( value : T ) -> Self ;
19
31
}
20
32
46
58
}
47
59
}
48
60
61
+ /// Same trait as [`std::convert::Into`].
62
+ ///
63
+ /// Because we are converting types that all live in another
64
+ // crate (`ruma`), we cannot implement `Into` on them, so we
65
+ // need a custom local trait, hence this `Into` trait.
49
66
pub trait Into < T > : Sized {
67
+ /// See [`std::convert::Into::into`].
50
68
#[ must_use]
51
69
fn into ( self ) -> T ;
52
70
}
62
80
}
63
81
}
64
82
83
+ /// HTTP types from MSC3575, renamed to match the Simplified MSC3575 namings.
65
84
pub mod msc3575 {
66
85
use super :: { simplified_msc3575 as sss, From } ;
67
86
use ruma:: { api:: client:: sync:: sync_events:: v4, events:: TimelineEventType } ;
@@ -79,6 +98,8 @@ pub mod msc3575 {
79
98
SlidingSyncRoomHero as ResponseRoomHero , SyncList as ResponseList ,
80
99
} ;
81
100
101
+ /// HTTP types for MSC3575 extensions, renamed to match the Simplified
102
+ /// MSC3575 namings.
82
103
pub mod extensions {
83
104
// Request types.
84
105
pub use super :: v4:: {
@@ -118,6 +139,8 @@ pub mod msc3575 {
118
139
s. room_details = From :: from ( value. room_details ) ;
119
140
s. include_heroes = value. include_heroes ;
120
141
s. filters = From :: from ( value. filters ) ;
142
+
143
+ // Defaults from Simplified MSC3575.
121
144
s. sort = vec ! [ "by_recency" . to_string( ) , "by_name" . to_string( ) ] ;
122
145
s. bump_event_types = vec ! [
123
146
TimelineEventType :: RoomMessage ,
@@ -247,6 +270,7 @@ pub mod msc3575 {
247
270
}
248
271
}
249
272
273
+ /// HTTP types from Simplified MSC3575.
250
274
pub mod simplified_msc3575 {
251
275
use super :: { msc3575 as ss, From } ;
252
276
pub use ruma:: api:: client:: sync:: sync_events:: v5:: * ;
0 commit comments