TimelineEvent

Struct TimelineEvent 

Source
pub struct TimelineEvent {
    pub kind: TimelineEventKind,
    pub timestamp: Option<MilliSecondsSinceUnixEpoch>,
    pub thread_summary: ThreadSummaryStatus,
    pub bundled_latest_thread_event: Option<Box<TimelineEvent>>,
    /* private fields */
}
Expand description

Represents a matrix room event that has been returned from a Matrix client-server API endpoint such as /sync or /messages, after initial processing.

The “initial processing” includes an attempt to decrypt encrypted events, so the main thing this adds over AnyTimelineEvent is information on encryption.

Fields§

§kind: TimelineEventKind

The event itself, together with any information on decryption.

§timestamp: Option<MilliSecondsSinceUnixEpoch>

The timestamp of the event. It’s the origin_server_ts value (if any), corrected if detected as malicious.

It can be None if the event has been serialised before the addition of this field, or if parsing the origin_server_ts value failed.

§thread_summary: ThreadSummaryStatus

If the event is part of a thread, a thread summary.

§bundled_latest_thread_event: Option<Box<TimelineEvent>>

The bundled latest thread event, if it was provided in the unsigned relations of this event.

Not serialized.

Implementations§

Source§

impl TimelineEvent

Source

pub fn from_plaintext(event: Raw<AnySyncTimelineEvent>) -> TimelineEvent

Create a new TimelineEvent from the given raw event.

This is a convenience constructor for a plaintext event when you don’t need to set push_action, for example inside a test.

Source

pub fn from_plaintext_with_max_timestamp( event: Raw<AnySyncTimelineEvent>, max_timestamp: MilliSecondsSinceUnixEpoch, ) -> TimelineEvent

Like TimelineEvent::from_plaintext but with a given max_timestamp.

Source

pub fn from_decrypted( decrypted: DecryptedRoomEvent, push_actions: Option<Vec<Action>>, ) -> TimelineEvent

Create a new TimelineEvent from a decrypted event.

Source

pub fn from_decrypted_with_max_timestamp( decrypted: DecryptedRoomEvent, push_actions: Option<Vec<Action>>, max_timestamp: MilliSecondsSinceUnixEpoch, ) -> TimelineEvent

Like TimelineEvent::from_decrypted but with a given max_timestamp.

Source

pub fn from_utd( event: Raw<AnySyncTimelineEvent>, utd_info: UnableToDecryptInfo, ) -> TimelineEvent

Create a new TimelineEvent to represent the given decryption failure.

Source

pub fn from_utd_with_max_timestamp( event: Raw<AnySyncTimelineEvent>, utd_info: UnableToDecryptInfo, max_timestamp: MilliSecondsSinceUnixEpoch, ) -> TimelineEvent

Like TimelineEvent::from_utd but with a given max_timestamp.

Source

pub fn to_decrypted( &self, decrypted: DecryptedRoomEvent, push_actions: Option<Vec<Action>>, ) -> TimelineEvent

Transform this TimelineEvent into another TimelineEvent with the TimelineEventKind::Decrypted kind.

§Panics

It panics (on debug builds only) if the kind already is TimelineEventKind::Decrypted.

Source

pub fn to_utd(&self, utd_info: UnableToDecryptInfo) -> TimelineEvent

Transform this TimelineEvent into another TimelineEvent with the TimelineEventKind::Decrypted kind.

§Panics

It panics (on debug builds only) if the kind already is TimelineEventKind::Decrypted.

Source

pub fn push_actions(&self) -> Option<&[Action]>

Read the current push actions.

Returns None if they were never computed, or if they could not be computed.

Source

pub fn set_push_actions(&mut self, push_actions: Vec<Action>)

Set the push actions for this event.

Source

pub fn event_id(&self) -> Option<OwnedEventId>

Get the event id of this TimelineEvent if the event has any valid id.

Source

pub fn raw(&self) -> &Raw<AnySyncTimelineEvent>

Returns a reference to the (potentially decrypted) Matrix event inside this TimelineEvent.

Source

pub fn replace_raw(&mut self, replacement: Raw<AnyTimelineEvent>)

Replace the raw event included in this item by another one.

Source

pub fn timestamp(&self) -> Option<MilliSecondsSinceUnixEpoch>

Get the timestamp.

If the timestamp is missing (most likely because the event has been created before the addition of the TimelineEvent::timestamp field), this method will try to extract it from the origin_server_ts value. If the origin_server_ts value is malicious, it will be capped to MilliSecondsSinceUnixEpoch::now. It means that the returned value might not be constant.

Source

pub fn timestamp_raw(&self) -> Option<MilliSecondsSinceUnixEpoch>

Get the timestamp value, without trying to backfill it if None.

Source

pub fn encryption_info(&self) -> Option<&Arc<EncryptionInfo>>

If the event was a decrypted event that was successfully decrypted, get its encryption info. Otherwise, None.

Source

pub fn into_raw(self) -> Raw<AnySyncTimelineEvent>

Takes ownership of this TimelineEvent, returning the (potentially decrypted) Matrix event within.

Trait Implementations§

Source§

impl Clone for TimelineEvent

Source§

fn clone(&self) -> TimelineEvent

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TimelineEvent

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for TimelineEvent

Source§

fn deserialize<D>( deserializer: D, ) -> Result<TimelineEvent, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Custom deserializer for TimelineEvent, to support older formats.

Ideally we might use an untagged enum and then convert from that; however, that doesn’t work due to a serde bug.

Instead, we first deserialize into an unstructured JSON map, and then inspect the json to figure out which format we have.

Source§

impl From<Event> for TimelineEvent

Source§

fn from(value: Event) -> TimelineEvent

Converts to this type from the input type.
Source§

impl<E> From<EventBuilder<E>> for TimelineEvent
where E: StaticEventContent<IsPrefix = False> + Serialize,

Source§

fn from(val: EventBuilder<E>) -> TimelineEvent

Converts to this type from the input type.
Source§

impl From<SyncTimelineEventDeserializationHelperV0> for TimelineEvent

Source§

fn from(value: SyncTimelineEventDeserializationHelperV0) -> TimelineEvent

Converts to this type from the input type.
Source§

impl From<SyncTimelineEventDeserializationHelperV1> for TimelineEvent

Source§

fn from(value: SyncTimelineEventDeserializationHelperV1) -> TimelineEvent

Converts to this type from the input type.
Source§

impl IndexableItem for TimelineEvent

Source§

type ItemId = OwnedEventId

Source§

fn id(&self) -> <TimelineEvent as IndexableItem>::ItemId

Return the identifier of the item.
Source§

impl Serialize for TimelineEvent

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Send for TimelineEvent

Source§

impl Sync for TimelineEvent

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
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> DeserialiseFromJs for T

Source§

fn deserialise_from_js(js: JsValue) -> Result<T, Error>

Deserialise a value from JS, most likely using serde_wasm_bindgen.
Source§

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

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Sync + Send>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

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

Source§

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

Create a new handle for an Arc value Read more
Source§

unsafe fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
Source§

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

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

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

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

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

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

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

Source§

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§

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>).
§

impl<T> Instrument for T

§

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

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

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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SerialiseToJs for T
where T: Serialize,

Source§

fn serialise_to_js(&self) -> Result<JsValue, Error>

Convert the type to a JsValue, most likely using serde_wasm_bindgen.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.
Source§

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

Source§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

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

Source§

impl<T> AsyncTraitDeps for T

Source§

impl<T> CloneAny for T
where T: Any + Clone,

Source§

impl<T> CloneAnySend for T
where T: Any + Send + Clone,

Source§

impl<T> CloneAnySendSync for T
where T: Any + Send + Sync + Clone,

Source§

impl<T> CloneAnySync for T
where T: Any + Sync + Clone,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> Fruit for T
where T: Send + Downcast,

§

impl<T> JsonCastable<CanonicalJsonValue> for T

§

impl<T> JsonCastable<Value> for T

Source§

impl<T> MaybeSendSync for T

Source§

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

Source§

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