Trait otrr::Host

source ·
pub trait Host {
    // Required methods
    fn inject(&self, account: &[u8], message: &[u8]);
    fn keypair(&self) -> Option<&Keypair>;
    fn keypair_identity(&self) -> &EdDSAKeyPair;
    fn keypair_forging(&self) -> &EdDSAKeyPair;
    fn query_smp_secret(&self, question: &[u8]) -> Option<Vec<u8>>;
    fn client_profile(&self) -> Vec<u8>;
    fn update_client_profile(&self, encoded_payload: Vec<u8>);

    // Provided method
    fn message_size(&self) -> usize { ... }
}
Expand description

Host represents the interface to the host application, for calling back into the messaging client.

Required Methods§

source

fn inject(&self, account: &[u8], message: &[u8])

Inject a message into the messaging’s transport stream. (I.e. protocol-related so not relevant to return to the client.) NOTE: otrr assumes that injection of the provided message into the transport succeeds.

source

fn keypair(&self) -> Option<&Keypair>

Acquire the long-term (legacy) DSA keypair from the host application. The long-term keypair, that is used for authentication purposes, is requested from the host application. This allows the host control over which keypair to provide for which account.

source

fn keypair_identity(&self) -> &EdDSAKeyPair

keypair_identity is the OTRv4 long-term (identity) keypair.

source

fn keypair_forging(&self) -> &EdDSAKeyPair

keypair_forging is the OTRv4 forging keypair.

source

fn query_smp_secret(&self, question: &[u8]) -> Option<Vec<u8>>

query_smp_secret triggers a query in the host application (chat client) to ask for the secret answer that is necessary to continue the SMP.

source

fn client_profile(&self) -> Vec<u8>

client_profile retrieves the client profile from the host application. An empty vector indicates that no client profile exists, therefore one will be generated from internally and keypairs will be queried from the host to complete a payload. update_client_profile is called with a (renewed) client profile payload that should be stored by the host/chat application.

source

fn update_client_profile(&self, encoded_payload: Vec<u8>)

update_client_profile sends the host an encoded client profile payload to be stored for use and restoring.

Provided Methods§

source

fn message_size(&self) -> usize

message_size queries the maximum message size accepted by the underlying transport.

It is expected that smaller message are allowed. The message size will be taken as a strict upper bound and it is expected that messages up to exactly that number in size are elligible for transport, while even a single byte more may mean – in the worst case – that the full message is dropped.

message_size is called for every message constructed. If name changes, connection changes, etc. are determining factors for the maximum message size, then the size only has to be stable for a single (OTR-encoded) message to be constructed.

Implementors§