pub struct Contextualized {
pub(crate) draft: Draft,
pub(crate) depth: u64,
pub(crate) room_version: KnownRoomVersionId,
pub(crate) auth_events: EventRefs,
pub(crate) prev_events: EventRefs,
pub(crate) prev_state: Option<EventRefs>,
pub(crate) membership: Option<MembershipState>,
pub(crate) origin: Option<OwnedServerName>,
pub(crate) origin_server_ts: MilliSecondsSinceUnixEpoch,
pub(crate) event_id: OwnedEventId,
pub(crate) room_id: OwnedRoomId,
pub(crate) hashes: EventHash,
}Expand description
State representing an event contextualized in the room DAG.
A contextualized event has been placed in the context of the room’s directed
acyclic graph (DAG) by adding auth_events and prev_events references,
along with the origin_server_ts and room version rules.
This state does not guarantee authorization - that check happens during
verification via super::RoomEvent<Signed>::verify().
Fields§
§draft: DraftThe draft event data
depth: u64The depth of the event
room_version: KnownRoomVersionIdRoom version for the event
auth_events: EventRefsThe auth events
prev_events: EventRefsThe previous events
prev_state: Option<EventRefs>The previous state field.
Not externally visible outside of the crate, but used by some room versions for nothing
membership: Option<MembershipState>The membership field.
Not externally visible outside of the crate, but used by some room versions for nothing
origin: Option<OwnedServerName>The origin field.
Not externally visible outside of NLE, but used by some room versions for nothing
origin_server_ts: MilliSecondsSinceUnixEpochThe origin server timestamp
event_id: OwnedEventIdThe event ID
room_id: OwnedRoomIdThe room ID
hashes: EventHashThe content hashes
Implementations§
Source§impl Contextualized
impl Contextualized
Sourcepub(crate) fn new(
draft: Draft,
depth: u64,
room_version: KnownRoomVersionId,
auth_events: EventRefs,
prev_events: EventRefs,
prev_state: Option<EventRefs>,
membership: Option<MembershipState>,
origin: Option<OwnedServerName>,
origin_server_ts: MilliSecondsSinceUnixEpoch,
event_id: Option<OwnedEventId>,
room_id: Option<OwnedRoomId>,
hashes: Option<EventHash>,
) -> Result<Self, EventContextualizationError>
pub(crate) fn new( draft: Draft, depth: u64, room_version: KnownRoomVersionId, auth_events: EventRefs, prev_events: EventRefs, prev_state: Option<EventRefs>, membership: Option<MembershipState>, origin: Option<OwnedServerName>, origin_server_ts: MilliSecondsSinceUnixEpoch, event_id: Option<OwnedEventId>, room_id: Option<OwnedRoomId>, hashes: Option<EventHash>, ) -> Result<Self, EventContextualizationError>
Contextualize an event
Can optionally be provided an event ID. If none is provided, one will always be generated, also for room versions 1 and 2.
Sourcepub(crate) fn from_signed_for_resign(
signed: Signed,
) -> Result<Self, SigningError>
pub(crate) fn from_signed_for_resign( signed: Signed, ) -> Result<Self, SigningError>
Recovers the Contextualized event from a Signed one for
re-signing, discarding the existing signatures and hashes.
Only m.room.member events are supported, since re-signing from an
already-signed state is currently only performed on member events.
Room-create events are rejected here rather than special-cased.
The content was already validated when the Signed event was built,
so the inner Contextualized is reused as-is without re-validation.
§Errors
Returns SigningError::InvalidContent if signed’s event type is not
m.room.member.
Sourcefn build_minimal_event_object(&self) -> Map<String, Value>
fn build_minimal_event_object(&self) -> Map<String, Value>
Builds the minimal event object for signing and hashing.
§Panics
Panics if a non-create event has no room ID.
Sourcepub(crate) fn build_canonical_event_object(
&self,
) -> Result<CanonicalJsonObject, SigningError>
pub(crate) fn build_canonical_event_object( &self, ) -> Result<CanonicalJsonObject, SigningError>
Builds the canonical event object for signing and hashing.
§Errors
Returns a SigningError if JSON canonicalization fails.
Sourcefn generate_hashes(&self) -> Result<EventHash, EventIdGenerationError>
fn generate_hashes(&self) -> Result<EventHash, EventIdGenerationError>
Generate the content hashes of the object
See here https://spec.matrix.org/latest/server-server-api/#calculating-the-content-hash-for-an-event
§Errors
Returns an EventIdGenerationError if the event cannot be
canonicalized or hashed, or if a room version 1 event has no server
name.
Sourcefn generate_event_id(
&self,
server_name: Option<&ServerName>,
) -> Result<OwnedEventId, EventIdGenerationError>
fn generate_event_id( &self, server_name: Option<&ServerName>, ) -> Result<OwnedEventId, EventIdGenerationError>
Generates an event ID matching the room version.
§Errors
Returns an EventIdGenerationError if the event cannot be
canonicalized or hashed, or if a room version 1 event has no server
name.
Trait Implementations§
Source§impl Clone for Contextualized
impl Clone for Contextualized
Source§fn clone(&self) -> Contextualized
fn clone(&self) -> Contextualized
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more