/// Get a tuple of device and one-time keys that need to be uploaded.
///
/// Returns an empty error if no keys need to be uploaded.
Get a tuple of device and one-time keys that need to be uploaded.
Returns an empty error if no keys need to be uploaded.
Get a tuple of device and one - time keys that need to be uploaded . Returns an empty error if no keys need to be uploaded .
pub(crate) async fn generate_one_time_keys(&self) -> Result<u64, ()> {
        // Only generate one-time keys if there aren't any, otherwise the caller
        // might have failed to upload them the last time this method was
        // called.
        if self.one_time_keys().await.curve25519().is_empty() {
            let count = self.uploaded_key_count();
            let max_keys = self.max_one_time_keys().await;
            let max_on_server = (max_keys as u64) / 2;
            if count >= (max_on_server) {
                return Err(());
            }
            let key_count = max_on_server - count;
            let key_count: usize = key_count.try_into().unwrap_or(max_keys);
            self.generate_one_time_keys_helper(key_count).await;
            Ok(key_count as u64)
        } else {
            Ok(0)
        }
    }
pub ( crate ) async fn generate_one_time_keys ( & self ) -> Result < u64 , ( ) > { // Only generate one-time keys if there aren't any, otherwise the caller // might have failed to upload them the last time this method was // called. if self . one_time_keys ( ) . await . curve25519 ( ) . is_empty ( ) { let count = self . uploaded_key_count ( ) ; let max_keys = self . max_one_time_keys ( ) . await ; let max_on_server = ( max_keys as u64 ) / 2 ; if count >= ( max_on_server ) { return Err ( ( ) ) ; } let key_count = max_on_server - count ; let key_count : usize = key_count . try_into ( ) . unwrap_or ( max_keys ) ; self . generate_one_time_keys_helper ( key_count ) . await ; Ok ( key_count as u64 ) } else { Ok ( 0 ) } }
Get a tuple of device and one-time keys that need to be uploaded.
Get a tuple of device and one - time keys that need to be uploaded .
&self