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