olm: Add initial higher level olm bindings.

master
Damir Jelić 2019-10-24 22:39:35 +02:00
parent e3d89f01f6
commit ee96ae00e4
3 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,10 @@
[package]
name = "nio-olm-rs"
version = "3.1.4-beta"
authors = ["Damir Jelić <poljar@termina.org.uk>"]
description = "Higher level bindings for the Olm C library"
license = "ISC"
edition = "2018"
[dependencies]
nio-olm-sys = { path = "../nio-olm-sys" }

View File

@ -0,0 +1,28 @@
use nio_olm_sys::OlmAccount;
pub struct Account {
account: *mut OlmAccount,
buffer: Vec<u8>,
}
impl Account {
#[allow(clippy::new_without_default)]
pub fn new() -> Account {
let (acc_ptr, account_data) = unsafe {
let account_size = nio_olm_sys::olm_account_size();
let account_data: Vec<u8> = vec![0; account_size];
let acc_ptr = nio_olm_sys::olm_account(account_data.as_ptr() as *mut _);
(acc_ptr, account_data)
};
Account {
account: acc_ptr,
buffer: account_data
}
}
}
#[test]
fn create_account() {
Account::new();
}

View File

@ -0,0 +1 @@
pub mod account;