OlmSession

Struct OlmSession 

Source
pub struct OlmSession { /* private fields */ }
Expand description

Either an outbound or inbound session for secure communication.

Implementations§

Source§

impl OlmSession

Source

pub fn session_id(&self) -> String

Retuns the identifier for this session. Will be the same for both ends of the conversation.

§C-API equivalent

olm_session_id

§Panics
  • OutputBufferTooSmall if the supplied output buffer for the ID was too small
  • on malformed UTF-8 coding of the session ID provided by libolm
Source

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
Source

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 with
  • InvalidBase64 if decoding the supplied pickled string slice fails
Source

pub fn encrypt(&self, plaintext: &str) -> OlmMessage

Encrypts a plaintext message using the session.

§C-API equivalent
  • olm_encrypt
§Panics
  • NotEnoughRandom for too little supplied random data
  • OutputBufferTooSmall for encrypted message
  • on malformed UTF-8 coding of the ciphertext provided by libolm
Source

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 arguments
  • BadMessageVersion on unsupported protocol version
  • BadMessageFormat on failing to decode the message
  • BadMessageMac on invalid message MAC
§Panics
  • OutputBufferTooSmall on plaintext output buffer
Source

pub fn has_received_message(&self) -> bool

Checker for any received messages for this session.

§C-API equivalent

olm_session_has_received_message

Source

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 in one_time_key_message
  • BadMessageVersion for message from unsupported protocol version
  • BadMessageFormat for failing to decode one_time_key_message
Source

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 in one_time_key_message
  • BadMessageVersion for message from unsupported protocol version
  • BadMessageFormat for failing to decode one_time_key_message

Trait Implementations§

Source§

impl Debug for OlmSession

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for OlmSession

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Ord for OlmSession

orders by unicode code points (which is a superset of ASCII)

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for OlmSession

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for OlmSession

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Eq for OlmSession

Source§

impl Send for OlmSession

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.