Struct matrix_sdk_crypto::olm::InboundGroupSession
source · 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
§type Error = SessionCreationError
type Error = SessionCreationError
source§impl TryFrom<&ExportedRoomKey> for InboundGroupSession
impl TryFrom<&ExportedRoomKey> for InboundGroupSession
§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,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§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