mx-bookmarks

A small bookmarks tui based on the matrix protocol and MSC2771
git clone git://archive.git.mtrnord.blog/MTRNord/mx-bookmarks.git
Log | Files | Refs | LICENSE

room.rs (1130B)


      1 //! Types for the *dev.nordgedanken.bookmarks.room* event.
      2 //! https://github.com/MTRNord/matrix-doc/blob/bookmarks-spec/proposals/2771-bookmarks.md
      3 
      4 use matrix_sdk::events::macros::BasicEventContent;
      5 use serde::{Deserialize, Serialize};
      6 
      7 use matrix_sdk::events::BasicEvent;
      8 use crate::extra_ruma::bookmarks::Bookmark;
      9 
     10 /// Informs the client of bookmarks in a room.
     11 pub type BookmarksEvent = BasicEvent<BookmarksEventContent>;
     12 
     13 /// Map of Bookmarks.
     14 pub type Bookmarks = Vec<Bookmark>;
     15 
     16 /// The payload for `BookmarksEvent`.
     17 #[derive(Clone, Debug, Deserialize, Serialize, BasicEventContent)]
     18 #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
     19 #[ruma_event(type = "dev.nordgedanken.bookmarks.room")]
     20 pub struct BookmarksEventContent {
     21     /// Map of Bookmarks.
     22     pub bookmarks: Bookmarks,
     23 }
     24 
     25 impl BookmarksEventContent {
     26     /// Creates a new `BookmarksEventContent` with the given `Bookmarks.
     27     pub fn new(bookmarks: Bookmarks) -> Self {
     28         Self { bookmarks }
     29     }
     30 }
     31 
     32 impl From<Bookmarks> for BookmarksEventContent {
     33     fn from(bookmarks: Bookmarks) -> Self {
     34         Self::new(bookmarks)
     35     }
     36 }