pub struct Timeline { /* private fields */ }
Expand description

A high-level view into a regular¹ room’s contents.

¹ This type is meant to be used in the context of rooms without a room_type, that is rooms that are primarily used to exchange text messages.

Implementations§

source§

impl Timeline

source

pub async fn paginate_backwards( &self, options: PaginationOptions<'_> ) -> Result<()>

Add more events to the start of the timeline.

source§

impl Timeline

source

pub fn builder(room: &Room) -> TimelineBuilder

Create a new TimelineBuilder for the given room.

source

pub fn room(&self) -> &Room

Returns the room for this timeline.

source

pub async fn clear(&self)

Clear all timeline items.

source

pub fn back_pagination_status(&self) -> Subscriber<BackPaginationStatus>

Subscribe to the back-pagination status of the timeline.

source

pub async fn retry_decryption<S: Into<String>>( &self, session_ids: impl IntoIterator<Item = S> )

Retry decryption of previously un-decryptable events given a list of session IDs whose keys have been imported.

§Examples
let path = PathBuf::from("/home/example/e2e-keys.txt");
let result =
    client.encryption().import_room_keys(path, "secret-passphrase").await?;

// Given a timeline for a specific room_id
if let Some(keys_for_users) = result.keys.get(room_id) {
    let session_ids = keys_for_users.values().flatten();
    timeline.retry_decryption(session_ids).await;
}
source

pub async fn item_by_event_id( &self, event_id: &EventId ) -> Option<EventTimelineItem>

Get the current timeline item for the given event ID, if any.

It’s preferable to store the timeline items in the model for your UI, if possible, instead of just storing IDs and coming back to the timeline object to look up items.

source

pub async fn latest_event(&self) -> Option<EventTimelineItem>

Get the latest of the timeline’s event items.

source

pub async fn subscribe( &self ) -> (Vector<Arc<TimelineItem>>, impl Stream<Item = VectorDiff<Arc<TimelineItem>>>)

Get the current timeline items, and a stream of changes.

You can poll this stream to receive updates. See futures_util::StreamExt for a high-level API on top of Stream.

source

pub async fn subscribe_batched( &self ) -> (Vector<Arc<TimelineItem>>, impl Stream<Item = Vec<VectorDiff<Arc<TimelineItem>>>>)

Get the current timeline items, and a batched stream of changes.

In contrast to subscribe, this stream can yield multiple diffs at once. The batching is done such that no arbitrary delays are added.

source

pub async fn send(&self, content: AnyMessageLikeEventContent)

Send a message to the room, and add it to the timeline as a local echo.

For simplicity, this method doesn’t currently allow custom message types.

If the encryption feature is enabled, this method will transparently encrypt the room message if the room is encrypted.

If sending the message fails, the local echo item will change its send_state to EventSendState::SendingFailed.

§Arguments
  • content - The content of the message event.
source

pub async fn send_reply( &self, content: RoomMessageEventContentWithoutRelation, reply_item: &EventTimelineItem, forward_thread: ForwardThread ) -> Result<(), UnsupportedReplyItem>

Send a reply to the given event.

Currently it only supports events with an event ID and JSON being available (which can be removed by local redactions). This is subject to change. Please check EventTimelineItem::can_be_replied_to to decide whether to render a reply button.

The sender of reply_item will be added to the mentions of the reply if and only if reply_item has not been written by the sender.

§Arguments
  • content - The content of the reply

  • reply_item - The event item you want to reply to

  • forward_thread - Usually Yes, unless you explicitly want to the reply to show up in the main timeline even though the reply_item is part of a thread

source

pub async fn edit( &self, new_content: RoomMessageEventContent, edit_item: &EventTimelineItem ) -> Result<(), UnsupportedEditItem>

Send an edit to the given event.

Currently only supports m.room.message events whose event ID is known. Please check EventTimelineItem::can_be_edited before calling this.

§Arguments
  • new_content - The content of the reply

  • edit_item - The event item you want to edit

source

pub async fn edit_poll( &self, fallback_text: impl Into<String>, poll: UnstablePollStartContentBlock, edit_item: &EventTimelineItem ) -> Result<(), UnsupportedEditItem>

source

pub async fn toggle_reaction( &self, annotation: &Annotation ) -> Result<(), Error>

Toggle a reaction on an event

Adds or redacts a reaction based on the state of the reaction at the time it is called.

When redacting an event, the redaction reason is not sent.

Ensures that only one reaction is sent at a time to avoid race conditions and spamming the homeserver with requests.

source

pub fn send_attachment( &self, filename: String, mime_type: Mime, config: AttachmentConfig ) -> SendAttachment<'_>

Sends an attachment to the room. It does not currently support local echoes

If the encryption feature is enabled, this method will transparently encrypt the room message if the room is encrypted.

§Arguments
  • filename - The filename of the file to be sent

  • mime_type - The attachment’s mime type

  • config - An attachment configuration object containing details about the attachment

like a thumbnail, its size, duration etc.

source

pub async fn retry_send(&self, txn_id: &TransactionId) -> Result<(), Error>

Retry sending a message that previously failed to send.

§Arguments
  • txn_id - The transaction ID of a local echo timeline item that has a send_state() of SendState::FailedToSend { .. }
source

pub async fn cancel_send(&self, txn_id: &TransactionId) -> bool

Discard a local echo for a message that failed to send.

Returns whether the local echo with the given transaction ID was found.

§Argument
  • txn_id - The transaction ID of a local echo timeline item that has a send_state() of SendState::FailedToSend { .. }. Note: A send state of SendState::NotYetSent might be supported in the future as well, but there can be no guarantee for that actually stopping the event from reaching the server.
source

pub async fn fetch_details_for_event( &self, event_id: &EventId ) -> Result<(), Error>

Fetch unavailable details about the event with the given ID.

This method only works for IDs of remote EventTimelineItems, to prevent losing details when a local echo is replaced by its remote echo.

This method tries to make all the requests it can. If an error is encountered for a given request, it is forwarded with the TimelineDetails::Error variant.

§Arguments
  • event_id - The event ID of the event to fetch details for.
§Errors

Returns an error if the identifier doesn’t match any event with a remote echo in the timeline, or if the event is removed from the timeline before all requests are handled.

source

pub async fn fetch_members(&self)

Fetch all member events for the room this timeline is displaying.

If the full member list is not known, sender profiles are currently likely not going to be available. This will be fixed in the future.

If fetching the members fails, any affected timeline items will have the sender_profile set to TimelineDetails::Error.

source

pub async fn latest_user_read_receipt( &self, user_id: &UserId ) -> Option<(OwnedEventId, Receipt)>

Get the latest read receipt for the given user.

Contrary to Room::load_user_receipt() that only keeps track of read receipts received from the homeserver, this keeps also track of implicit read receipts in this timeline, i.e. when a room member sends an event.

source

pub async fn latest_user_read_receipt_timeline_event_id( &self, user_id: &UserId ) -> Option<OwnedEventId>

Get the ID of the timeline event with the latest read receipt for the given user.

In contrary to Self::latest_user_read_receipt(), this allows to know the position of the read receipt in the timeline even if the event it applies to is not visible in the timeline, unless the event is unknown by this timeline.

source

pub async fn send_single_receipt( &self, receipt_type: ReceiptType, thread: ReceiptThread, event_id: OwnedEventId ) -> Result<bool>

Send the given receipt.

This uses Room::send_single_receipt internally, but checks first if the receipt points to an event in this timeline that is more recent than the current ones, to avoid unnecessary requests.

Returns a boolean indicating if it sent the request or not.

source

pub async fn send_multiple_receipts(&self, receipts: Receipts) -> Result<()>

Send the given receipts.

This uses Room::send_multiple_receipts internally, but checks first if the receipts point to events in this timeline that are more recent than the current ones, to avoid unnecessary requests.

source

pub async fn mark_as_read(&self, receipt_type: ReceiptType) -> Result<bool>

Mark the room as read by sending an unthreaded read receipt on the latest event, be it visible or not.

This works even if the latest event belongs to a thread, as a threaded reply also belongs to the unthreaded timeline. No threaded receipt will be sent here (see also #3123).

Returns a boolean indicating if we sent the request or not.

Trait Implementations§

source§

impl Debug for Timeline

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CompatExt for T

§

fn compat(self) -> Compat<T>

Applies the [Compat] adapter by value. Read more
§

fn compat_ref(&self) -> Compat<&T>

Applies the [Compat] adapter by shared reference. Read more
§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the [Compat] adapter by mutable reference. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T, UT> HandleAlloc<UT> for T
where T: Send + Sync,

§

fn new_handle(value: Arc<T>) -> Handle

Create a new handle for an Arc value Read more
§

fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
§

fn consume_handle(handle: Handle) -> Arc<T>

Consume a handle, getting back the initial Arc<>
§

fn get_arc(handle: Handle) -> Arc<Self>

Get a clone of the Arc<> using a “borrowed” handle. Read more
§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

§

const WITNESS: W = W::MAKE

A constant of the type witness
§

impl<T> Identity for T
where T: ?Sized,

§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> IntoResult<T> for T

§

type Err = Infallible

§

fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<T> Any for T
where T: Any,

source§

impl<T> AsyncTraitDeps for T

source§

impl<T> SendOutsideWasm for T
where T: Send,

source§

impl<T> SyncOutsideWasm for T
where T: Sync,