pub struct InboundGroupSession {
pub sender_data: SenderData,
pub room_id: OwnedRoomId,
/* private fields */
}
Expand description
A structure representing an inbound group session.
Inbound group sessions, also known as “room keys”, are used to facilitate the exchange of room messages among a group of participants. The inbound variant of the group session is used to decrypt the room messages.
This struct wraps the vodozemac type of the same name, and adds additional Matrix-specific data to it. Additionally, the wrapper ensures thread-safe access of the vodozemac type.
Fields§
§sender_data: SenderData
Information about the sender of this session and how much we trust that information. Holds the information we have about the device that created the session, or, if we can use that device information to find the sender’s cross-signing identity, holds the user ID and cross-signing key.
room_id: OwnedRoomId
The Room this GroupSession belongs to
Implementations§
Source§impl InboundGroupSession
impl InboundGroupSession
Sourcepub fn new(
sender_key: Curve25519PublicKey,
signing_key: Ed25519PublicKey,
room_id: &RoomId,
session_key: &SessionKey,
sender_data: SenderData,
encryption_algorithm: EventEncryptionAlgorithm,
history_visibility: Option<HistoryVisibility>,
) -> Result<Self, SessionCreationError>
pub fn new( sender_key: Curve25519PublicKey, signing_key: Ed25519PublicKey, room_id: &RoomId, session_key: &SessionKey, sender_data: SenderData, encryption_algorithm: EventEncryptionAlgorithm, history_visibility: Option<HistoryVisibility>, ) -> Result<Self, SessionCreationError>
Create a new inbound group session for the given room.
These sessions are used to decrypt room messages.
§Arguments
-
sender_key
- The public Curve25519 key of the account that sent us the session. -
signing_key
- The public Ed25519 key of the account that sent us the session. -
room_id
- The id of the room that the session is used in. -
session_key
- The private session key that is used to decrypt messages. -
sender_data
- Information about the sender of the to-device message that established this session.
Sourcepub fn from_export(
exported_session: &ExportedRoomKey,
) -> Result<Self, SessionCreationError>
pub fn from_export( exported_session: &ExportedRoomKey, ) -> Result<Self, SessionCreationError>
Create a InboundGroupSession from an exported version of the group session.
Most notably this can be called with an ExportedRoomKey
from a
previous export()
call.
Sourcepub async fn pickle(&self) -> PickledInboundGroupSession
pub async fn pickle(&self) -> PickledInboundGroupSession
Store the group session as a base64 encoded string.
§Arguments
pickle_mode
- The mode that was used to pickle the group session, either an unencrypted mode or an encrypted using passphrase.
Sourcepub async fn export(&self) -> ExportedRoomKey
pub async fn export(&self) -> ExportedRoomKey
Export this session at the first known message index.
If only a limited part of this session should be exported use
export_at_index()
.
Sourcepub fn sender_key(&self) -> Curve25519PublicKey
pub fn sender_key(&self) -> Curve25519PublicKey
Get the sender key that this session was received from.
Sourcepub fn reset_backup_state(&self)
pub fn reset_backup_state(&self)
Reset the backup state of the inbound group session.
Sourcepub fn mark_as_backed_up(&self)
pub fn mark_as_backed_up(&self)
For testing, allow to manually mark this GroupSession to have been backed up
Sourcepub fn signing_keys(&self) -> &SigningKeys<DeviceKeyAlgorithm>
pub fn signing_keys(&self) -> &SigningKeys<DeviceKeyAlgorithm>
Get the map of signing keys this session was received from.
Sourcepub async fn export_at_index(&self, message_index: u32) -> ExportedRoomKey
pub async fn export_at_index(&self, message_index: u32) -> ExportedRoomKey
Export this session at the given message index.
Sourcepub fn from_pickle(
pickle: PickledInboundGroupSession,
) -> Result<Self, PickleError>
pub fn from_pickle( pickle: PickledInboundGroupSession, ) -> Result<Self, PickleError>
Restore a Session from a previously pickled string.
Returns the restored group session or a UnpicklingError
if there
was an error.
§Arguments
-
pickle
- The pickled version of theInboundGroupSession
. -
pickle_mode
- The mode that was used to pickle the session, either an unencrypted mode or an encrypted using passphrase.
Sourcepub fn session_id(&self) -> &str
pub fn session_id(&self) -> &str
Returns the unique identifier for this session.
Sourcepub fn algorithm(&self) -> &EventEncryptionAlgorithm
pub fn algorithm(&self) -> &EventEncryptionAlgorithm
The algorithm that this inbound group session is using to decrypt events.
Sourcepub fn first_known_index(&self) -> u32
pub fn first_known_index(&self) -> u32
Get the first message index we know how to decrypt.
Sourcepub fn has_been_imported(&self) -> bool
pub fn has_been_imported(&self) -> bool
Has the session been imported from a file or server-side backup? As
opposed to being directly received as an m.room_key
event.
Sourcepub async fn compare(&self, other: &InboundGroupSession) -> SessionOrdering
pub async fn compare(&self, other: &InboundGroupSession) -> SessionOrdering
Check if the InboundGroupSession
is better than the given other
InboundGroupSession
Sourcepub async fn to_backup(&self) -> BackedUpRoomKey
pub async fn to_backup(&self) -> BackedUpRoomKey
Export the inbound group session into a format that can be uploaded to the server as a backup.
Sourcepub async fn decrypt(
&self,
event: &EncryptedEvent,
) -> Result<(JsonObject, u32), MegolmError>
pub async fn decrypt( &self, event: &EncryptedEvent, ) -> Result<(JsonObject, u32), MegolmError>
Sourcepub fn sender_data_type(&self) -> SenderDataType
pub fn sender_data_type(&self) -> SenderDataType
Return the SenderDataType
of our SenderData
. This is used during
serialization, to allow us to store the type in a separate queryable
column/property.
Trait Implementations§
Source§impl Clone for InboundGroupSession
impl Clone for InboundGroupSession
Source§fn clone(&self) -> InboundGroupSession
fn clone(&self) -> InboundGroupSession
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for InboundGroupSession
Available on non-tarpaulin_include
only.
impl Debug for InboundGroupSession
tarpaulin_include
only.Source§impl From<&ForwardedMegolmV1AesSha2Content> for InboundGroupSession
impl From<&ForwardedMegolmV1AesSha2Content> for InboundGroupSession
Source§fn from(value: &ForwardedMegolmV1AesSha2Content) -> Self
fn from(value: &ForwardedMegolmV1AesSha2Content) -> Self
Source§impl From<&ForwardedMegolmV2AesSha2Content> for InboundGroupSession
impl From<&ForwardedMegolmV2AesSha2Content> for InboundGroupSession
Source§fn from(value: &ForwardedMegolmV2AesSha2Content) -> Self
fn from(value: &ForwardedMegolmV2AesSha2Content) -> Self
Source§impl From<&InboundGroupSession> for RoomKeyInfo
impl From<&InboundGroupSession> for RoomKeyInfo
Source§fn from(group_session: &InboundGroupSession) -> Self
fn from(group_session: &InboundGroupSession) -> Self
Source§impl PartialEq for InboundGroupSession
impl PartialEq for InboundGroupSession
Source§impl TryFrom<&DecryptedOlmV1Event<ForwardedRoomKeyContent>> for InboundGroupSession
impl TryFrom<&DecryptedOlmV1Event<ForwardedRoomKeyContent>> for InboundGroupSession
Source§type Error = SessionCreationError
type Error = SessionCreationError
Source§impl TryFrom<&ExportedRoomKey> for InboundGroupSession
impl TryFrom<&ExportedRoomKey> for InboundGroupSession
Source§type Error = SessionCreationError
type Error = SessionCreationError
Auto Trait Implementations§
impl Freeze for InboundGroupSession
impl !RefUnwindSafe for InboundGroupSession
impl Send for InboundGroupSession
impl Sync for InboundGroupSession
impl Unpin for InboundGroupSession
impl !UnwindSafe for InboundGroupSession
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> CompatExt for T
impl<T> CompatExt for T
Source§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
Source§fn consume_handle(handle: Handle) -> Arc<T>
fn consume_handle(handle: Handle) -> Arc<T>
Arc<>
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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