pub struct OlmSession { /* private fields */ }
Expand description
Either an outbound or inbound session for secure communication.
Implementations§
Source§impl OlmSession
impl OlmSession
Sourcepub fn session_id(&self) -> String
pub fn session_id(&self) -> String
Sourcepub fn pickle(&self, mode: PicklingMode) -> String
pub fn pickle(&self, mode: PicklingMode) -> String
Serialises an OlmSession
to encrypted base64.
§C-API equivalent
olm_pickle_session
§Panics
OUTPUT_BUFFER_TOO_SMALL
for OlmSession’s pickled buffer- on malformed UTF-8 coding of the pickling provided by libolm
Sourcepub fn unpickle(
pickled: String,
mode: PicklingMode,
) -> Result<Self, OlmSessionError>
pub fn unpickle( pickled: String, mode: PicklingMode, ) -> Result<Self, OlmSessionError>
Deserialises from encrypted base64 that was previously obtained by pickling an OlmSession
.
§C-API equivalent
olm_unpickle_session
§Errors
BadAccountKey
if the key doesn’t match the one the session was encrypted withInvalidBase64
if decoding the suppliedpickled
string slice fails
Sourcepub fn encrypt(&self, plaintext: &str) -> OlmMessage
pub fn encrypt(&self, plaintext: &str) -> OlmMessage
Sourcepub fn decrypt(&self, message: OlmMessage) -> Result<String, OlmSessionError>
pub fn decrypt(&self, message: OlmMessage) -> Result<String, OlmSessionError>
Decrypts a message using this session. Decoding is lossy, meaing if
the decrypted plaintext contains invalid UTF-8 symbols, they will
be returned as U+FFFD
(�).
§C-API equivalent
olm_decrypt
§Errors
InvalidBase64
on invalid base64 coding for supplied argumentsBadMessageVersion
on unsupported protocol versionBadMessageFormat
on failing to decode the messageBadMessageMac
on invalid message MAC
§Panics
OutputBufferTooSmall
on plaintext output buffer
Sourcepub fn has_received_message(&self) -> bool
pub fn has_received_message(&self) -> bool
Checker for any received messages for this session.
§C-API equivalent
olm_session_has_received_message
Sourcepub fn matches_inbound_session(
&self,
message: PreKeyMessage,
) -> Result<bool, OlmSessionError>
pub fn matches_inbound_session( &self, message: PreKeyMessage, ) -> Result<bool, OlmSessionError>
Checks if the ‘prekey’ message is for this in-bound session.
§C-API equivalent
olm_matches_inbound_session
§Errors
InvalidBase64
for failing to decode base64 inone_time_key_message
BadMessageVersion
for message from unsupported protocol versionBadMessageFormat
for failing to decodeone_time_key_message
Sourcepub fn matches_inbound_session_from(
&self,
their_identity_key: &str,
message: PreKeyMessage,
) -> Result<bool, OlmSessionError>
pub fn matches_inbound_session_from( &self, their_identity_key: &str, message: PreKeyMessage, ) -> Result<bool, OlmSessionError>
Checks if the ‘prekey’ message is for this in-bound session.
§C-API equivalent
olm_matches_inbound_session
§Errors
InvalidBase64
for failing to decode base64 inone_time_key_message
BadMessageVersion
for message from unsupported protocol versionBadMessageFormat
for failing to decodeone_time_key_message
Trait Implementations§
Source§impl Debug for OlmSession
impl Debug for OlmSession
Source§impl Drop for OlmSession
impl Drop for OlmSession
Source§impl Ord for OlmSession
orders by unicode code points (which is a superset of ASCII)
impl Ord for OlmSession
orders by unicode code points (which is a superset of ASCII)
Source§impl PartialEq for OlmSession
impl PartialEq for OlmSession
Source§impl PartialOrd for OlmSession
impl PartialOrd for OlmSession
impl Eq for OlmSession
impl Send for OlmSession
Auto Trait Implementations§
impl Freeze for OlmSession
impl RefUnwindSafe for OlmSession
impl !Sync for OlmSession
impl Unpin for OlmSession
impl UnwindSafe for OlmSession
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
Mutably borrows from an owned value. Read more