Struct matrix_sdk_crypto::olm::Session
source · pub struct Session {
pub inner: Arc<Mutex<Session>>,
pub session_id: Arc<str>,
pub sender_key: Curve25519PublicKey,
pub our_device_keys: DeviceKeys,
pub created_using_fallback_key: bool,
pub creation_time: SecondsSinceUnixEpoch,
pub last_use_time: SecondsSinceUnixEpoch,
}
Expand description
Cryptographic session that enables secure communication between two
Account
s
Fields§
§inner: Arc<Mutex<Session>>
The OlmSession
session_id: Arc<str>
Our sessionId
sender_key: Curve25519PublicKey
The Key of the sender
our_device_keys: DeviceKeys
Our own signed device keys
created_using_fallback_key: bool
Has this been created using the fallback key
creation_time: SecondsSinceUnixEpoch
When the session was created
last_use_time: SecondsSinceUnixEpoch
When the session was last used
Implementations§
source§impl Session
impl Session
sourcepub async fn decrypt(
&mut self,
message: &OlmMessage,
) -> Result<String, DecryptionError>
pub async fn decrypt( &mut self, message: &OlmMessage, ) -> Result<String, DecryptionError>
Decrypt the given Olm message.
Returns the decrypted plaintext or a DecryptionError
if decryption
failed.
§Arguments
message
- The Olm message that should be decrypted.
sourcepub fn sender_key(&self) -> Curve25519PublicKey
pub fn sender_key(&self) -> Curve25519PublicKey
Get the sender key that was used to establish this Session.
sourcepub async fn session_config(&self) -> SessionConfig
pub async fn session_config(&self) -> SessionConfig
Get the SessionConfig
that this session is using.
sourcepub async fn algorithm(&self) -> EventEncryptionAlgorithm
pub async fn algorithm(&self) -> EventEncryptionAlgorithm
Get the EventEncryptionAlgorithm
of this Session
.
sourcepub async fn encrypt(
&mut self,
recipient_device: &DeviceData,
event_type: &str,
content: impl Serialize,
message_id: Option<String>,
) -> Result<Raw<ToDeviceEncryptedEventContent>, OlmError>
pub async fn encrypt( &mut self, recipient_device: &DeviceData, event_type: &str, content: impl Serialize, message_id: Option<String>, ) -> Result<Raw<ToDeviceEncryptedEventContent>, OlmError>
Encrypt the given event content as an m.room.encrypted event content.
§Arguments
-
recipient_device
- The device for which this message is going to be encrypted, this needs to be the device that was used to create this session with. -
event_type
- The type of the event content. -
content
- The content of the event.
sourcepub fn session_id(&self) -> &str
pub fn session_id(&self) -> &str
Returns the unique identifier for this session.
sourcepub async fn pickle(&self) -> PickledSession
pub async fn pickle(&self) -> PickledSession
Store the session as a base64 encoded string.
§Arguments
pickle_mode
- The mode that was used to pickle the session, either an unencrypted mode or an encrypted using passphrase.
sourcepub fn from_pickle(
our_device_keys: DeviceKeys,
pickle: PickledSession,
) -> Result<Self, SessionUnpickleError>
pub fn from_pickle( our_device_keys: DeviceKeys, pickle: PickledSession, ) -> Result<Self, SessionUnpickleError>
Restore a Session from a previously pickled string.
Returns the restored Olm Session or a SessionUnpicklingError
if there
was an error.
§Arguments
-
our_device_keys
- Our own signed device keys. -
pickle
- The pickled version of theSession
.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Session
impl !RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl !UnwindSafe for Session
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