olm: Add initial higher level olm bindings.
This commit is contained in:
parent
e3d89f01f6
commit
ee96ae00e4
3 changed files with 39 additions and 0 deletions
10
nio-olm/nio-olm-rs/Cargo.toml
Normal file
10
nio-olm/nio-olm-rs/Cargo.toml
Normal 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" }
|
28
nio-olm/nio-olm-rs/src/account.rs
Normal file
28
nio-olm/nio-olm-rs/src/account.rs
Normal 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();
|
||||
}
|
1
nio-olm/nio-olm-rs/src/lib.rs
Normal file
1
nio-olm/nio-olm-rs/src/lib.rs
Normal file
|
@ -0,0 +1 @@
|
|||
pub mod account;
|
Loading…
Reference in a new issue