Struct olm_rs::session::OlmSession[][src]

pub struct OlmSession { /* fields omitted */ }

Either an outbound or inbound session for secure communication.

Implementations

impl OlmSession[src]

pub fn session_id(&self) -> String[src]

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

pub fn pickle(&self, mode: PicklingMode) -> String[src]

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

pub fn unpickle(
    mut pickled: String,
    mode: PicklingMode
) -> Result<Self, OlmSessionError>
[src]

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

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

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

pub fn decrypt(&self, message: OlmMessage) -> Result<String, OlmSessionError>[src]

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

pub fn has_received_message(&self) -> bool[src]

Checker for any received messages for this session.

C-API equivalent

olm_session_has_received_message

pub fn matches_inbound_session(
    &self,
    mut message: PreKeyMessage
) -> Result<bool, OlmSessionError>
[src]

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

pub fn matches_inbound_session_from(
    &self,
    their_identity_key: &str,
    mut message: PreKeyMessage
) -> Result<bool, OlmSessionError>
[src]

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

impl Debug for OlmSession[src]

impl Drop for OlmSession[src]

impl Eq for OlmSession[src]

impl Ord for OlmSession[src]

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

impl PartialEq<OlmSession> for OlmSession[src]

impl PartialOrd<OlmSession> for OlmSession[src]

impl Send for OlmSession[src]

impl StructuralEq for OlmSession[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.