Struct matrix_sdk_crypto::olm::Session
source · [−]pub struct Session {
pub user_id: Arc<UserId>,
pub device_id: Arc<DeviceId>,
pub our_identity_keys: Arc<IdentityKeys>,
pub inner: Arc<Mutex<InnerSession>>,
pub session_id: Arc<str>,
pub sender_key: Curve25519PublicKey,
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
user_id: Arc<UserId>
The UserId
associated with this session
device_id: Arc<DeviceId>
The specific DeviceId
associated with this session
our_identity_keys: Arc<IdentityKeys>
The IdentityKeys
associated with this session
inner: Arc<Mutex<InnerSession>>
The OlmSession
session_id: Arc<str>
Our sessionId
sender_key: Curve25519PublicKey
The Key of the sender
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
sourceimpl 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 an DecrypitonError
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 encrypt(
&mut self,
recipient_device: &ReadOnlyDevice,
content: AnyToDeviceEventContent
) -> Result<ToDeviceRoomEncryptedEventContent, OlmError>
pub async fn encrypt(
&mut self,
recipient_device: &ReadOnlyDevice,
content: AnyToDeviceEventContent
) -> Result<ToDeviceRoomEncryptedEventContent, OlmError>
Encrypt the given event content 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. -
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(
user_id: Arc<UserId>,
device_id: Arc<DeviceId>,
our_identity_keys: Arc<IdentityKeys>,
pickle: PickledSession
) -> Self
pub fn from_pickle(
user_id: Arc<UserId>,
device_id: Arc<DeviceId>,
our_identity_keys: Arc<IdentityKeys>,
pickle: PickledSession
) -> Self
Restore a Session from a previously pickled string.
Returns the restored Olm Session or a SessionUnpicklingError
if there
was an error.
Arguments
-
user_id
- Our own user id that the session belongs to. -
device_id
- Our own device ID that the session belongs to. -
our_idenity_keys
- An clone of the Arc to our own identity keys. -
pickle
- The pickled version of theSession
. -
pickle_mode
- The mode that was used to pickle the session, either an unencrypted mode or an encrypted using passphrase.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl !UnwindSafe for Session
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more