update to autobindings 0.0.5 / ~ cwtchui 1.12 / cwtch 0.20.8

This commit is contained in:
Dan Ballard 2023-06-26 00:03:04 -07:00
parent 4f49da65cc
commit 94504c1dbe
8 changed files with 341 additions and 114 deletions

219
Cargo.lock generated
View File

@ -8,6 +8,35 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "bindgen"
version = "0.65.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cfdf7b466f9a4903edc73f95d6d2bcd5baf8ae620638762244d3f60143643cc5"
dependencies = [
"bitflags",
"cexpr",
"clang-sys",
"lazy_static",
"lazycell",
"log",
"peeking_take_while",
"prettyplease",
"proc-macro2",
"quote",
"regex",
"rustc-hash",
"shlex",
"syn 2.0.22",
"which",
]
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "block-buffer"
version = "0.10.2"
@ -17,6 +46,15 @@ dependencies = [
"generic-array",
]
[[package]]
name = "cexpr"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
dependencies = [
"nom",
]
[[package]]
name = "cfg-if"
version = "1.0.0"
@ -36,6 +74,17 @@ dependencies = [
"winapi",
]
[[package]]
name = "clang-sys"
version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f"
dependencies = [
"glob",
"libc",
"libloading",
]
[[package]]
name = "cpufeatures"
version = "0.2.1"
@ -76,7 +125,7 @@ dependencies = [
"proc-macro2",
"quote",
"strsim",
"syn",
"syn 1.0.85",
]
[[package]]
@ -87,7 +136,7 @@ checksum = "72c41b3b7352feb3211a0d743dc5700a4e3b60f51bd2b368892d1e0f9a95f44b"
dependencies = [
"darling_core",
"quote",
"syn",
"syn 1.0.85",
]
[[package]]
@ -100,6 +149,12 @@ dependencies = [
"crypto-common",
]
[[package]]
name = "either"
version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
[[package]]
name = "fnv"
version = "1.0.7"
@ -116,6 +171,12 @@ dependencies = [
"version_check",
]
[[package]]
name = "glob"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
[[package]]
name = "hex-literal"
version = "0.3.4"
@ -135,15 +196,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35"
[[package]]
name = "libc"
version = "0.2.112"
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "lazycell"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "libc"
version = "0.2.147"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
[[package]]
name = "libcwtch"
version = "0.4.2"
version = "0.6.0"
dependencies = [
"bindgen",
"chrono",
"hex-literal",
"libc",
@ -154,6 +228,44 @@ dependencies = [
"sha2",
]
[[package]]
name = "libloading"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
dependencies = [
"cfg-if",
"winapi",
]
[[package]]
name = "log"
version = "0.4.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4"
[[package]]
name = "memchr"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]]
name = "minimal-lexical"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "nom"
version = "7.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
dependencies = [
"memchr",
"minimal-lexical",
]
[[package]]
name = "num-integer"
version = "0.1.45"
@ -174,23 +286,66 @@ dependencies = [
]
[[package]]
name = "proc-macro2"
version = "1.0.36"
name = "once_cell"
version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
[[package]]
name = "peeking_take_while"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
[[package]]
name = "prettyplease"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9825a04601d60621feed79c4e6b56d65db77cdca55cef43b46b0de1096d1c282"
dependencies = [
"unicode-xid",
"proc-macro2",
"syn 2.0.22",
]
[[package]]
name = "proc-macro2"
version = "1.0.63"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.14"
version = "1.0.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d"
checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488"
dependencies = [
"proc-macro2",
]
[[package]]
name = "regex"
version = "1.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f"
dependencies = [
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78"
[[package]]
name = "rustc-hash"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "rustversion"
version = "1.0.6"
@ -220,7 +375,7 @@ checksum = "ed201699328568d8d08208fdd080e3ff594e6c422e438b6705905da01005d537"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 1.0.85",
]
[[package]]
@ -242,7 +397,7 @@ checksum = "a2ad84e47328a31223de7fed7a4f5087f2d6ddfe586cf3ca25b7a165bc0a5aed"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 1.0.85",
]
[[package]]
@ -265,7 +420,7 @@ dependencies = [
"darling",
"proc-macro2",
"quote",
"syn",
"syn 1.0.85",
]
[[package]]
@ -279,6 +434,12 @@ dependencies = [
"digest",
]
[[package]]
name = "shlex"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
[[package]]
name = "strsim"
version = "0.10.0"
@ -296,6 +457,17 @@ dependencies = [
"unicode-xid",
]
[[package]]
name = "syn"
version = "2.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2efbeae7acf4eabd6bcdcbd11c92f45231ddda7539edc7806bd1a04a03b24616"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "time"
version = "0.1.44"
@ -313,6 +485,12 @@ version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"
[[package]]
name = "unicode-ident"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0"
[[package]]
name = "unicode-xid"
version = "0.2.2"
@ -331,6 +509,17 @@ version = "0.10.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
[[package]]
name = "which"
version = "4.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269"
dependencies = [
"either",
"libc",
"once_cell",
]
[[package]]
name = "winapi"
version = "0.3.9"

View File

@ -1,6 +1,6 @@
[package]
name = "libcwtch"
version = "0.5.0"
version = "0.6.0"
authors = ["Dan Ballard <dan@mindstab.net>"]
edition = "2018"
license = "MIT"
@ -12,6 +12,7 @@ documentation = "https://docs.rs/libcwtch/"
[build-dependencies]
hex-literal = "0.3.4"
sha2 = "0.10.1"
bindgen = "0.65.1"
[dependencies]
libc = "0.2"

View File

@ -8,21 +8,12 @@ Example echobot in examples/echobot.rs (`cargo run --example echobot` -- assumes
### Updating libCwtch and bingings.rs with Bindgen
```sh
cargo install bindgen
```
libCwtch.so version is specified in build.rs. If updating, also download the corresponding libCwtch.h and delete
the 'preamble from import "C"' section as it imports headers required for the C lib to compile
but that we don't want to create rust bindings for (like importing stdlib.h). Then:
```sh
bindgen libCwtch.h -o src/cwtchlib_go/bindings.rs
```
but that we don't want to create rust bindings for (like importing stdlib.h). `cargo build` automatically calls
`bindgen` for us and will regenerate `src/cwtchlib_go/bindings.rs` if libCwtch.h has changed.
While developing you can use the `LCG_DIR` environment variable to specify the directory containing a local `libCwtch.so`
library to override the default one.
This is useful in cases where you are adding or updating APIs prior to a release.
### Todo
This is useful in cases where you are adding or updating APIs prior to a release.

View File

@ -1,6 +1,6 @@
use std::{env, io};
use std::fs;
use std::path::Path;
use std::path::{Path, PathBuf};
use std::process::Command;
use hex_literal::hex;
@ -18,11 +18,33 @@ fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=libCwtch.h");
// The bindgen::Builder is the main entry point
// to bindgen, and lets you build up options for
// the resulting bindings.
let bindings = bindgen::Builder::default()
// The input header we would like to generate
// bindings for.
.header("libCwtch.h")
// Tell cargo to invalidate the built crate whenever any of the
// included header files changed.
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
// Finish the builder and generate the bindings.
.generate()
// Unwrap the Result and panic on failure.
.expect("Unable to generate bindings");
// Write the bindings to the $OUT_DIR/bindings.rs file.
let out_path = PathBuf::from("src/cwtchlib_go");
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings!");
let lib_cwtch_path = Path::new(&out_dir).join("libCwtch.so");
if std::env::var("LCG_DIR").is_err() {
// https://git.openprivacy.ca/cwtch.im/libcwtch-go/releases v1.7.1
Command::new("wget")
.arg("https://git.openprivacy.ca/attachments/5fa8e7f5-13c2-4634-b531-0398cd7c6353")
.arg("https://git.openprivacy.ca/attachments/cacefb43-8292-4350-a1d6-b416847854aa")
.arg("-O")
.arg(lib_cwtch_path.clone())
.output()
@ -33,7 +55,7 @@ fn main() {
io::copy(&mut file, &mut hasher).expect("failed to copy file into hasher");
let hash_bytes = hasher.finalize();
assert_eq!(hash_bytes[..], hex!("dc53eb4948357128a72f740cf48402e966e886c60bc150bd26d10d3c98dda64c3658322c15f3b93781365d40dd4315b1056fb9aa6ee3a56f8968d4bff1bc8f0d")[..]);
assert_eq!(hash_bytes[..], hex!("1b05a0e6a7ced043aa441dfecb0a3c7d0412955de57946299bb80a763a54620f56cc3b08dde82913a0cd626668a26a0609d44015f7eb6f738789f3100c99ec14")[..]);
} else {
let local_lcg = Path::new(std::env::var("LCG_DIR").unwrap().as_str()).join("libCwtch.so");
fs::copy(local_lcg, lib_cwtch_path).expect("could not find local lcg");

View File

@ -85,6 +85,7 @@ extern void c_SetConversationAttribute(char* profile_ptr, int profile_len, int c
extern char* c_GetConversationAttribute(char* profile_ptr, int profile_len, int conversation_id, char* key_ptr, int key_len);
extern void c_ResetTor();
extern void c_UpdateSettings(char* json_ptr, int json_len);
extern char* c_GetDebugInfo();
extern void c_ActivatePeerEngine(char* onion_ptr, int onion_len);
extern void c_DeactivatePeerEngine(char* onion_ptr, int onion_len);
extern void c_CreateProfile(char* name_ptr, int name_len, char* password_ptr, int password_len, char autostart1);
@ -99,29 +100,30 @@ extern void c_AcceptConversation(char* onion_ptr, int onion_len, int conversatio
extern void c_BlockConversation(char* onion_ptr, int onion_len, int conversation);
extern void c_UnblockConversation(char* onion_ptr, int onion_len, int conversation);
extern void c_DeleteConversation(char* onion_ptr, int onion_len, int conversation);
extern char* c_SendMessage(char* onion_ptr, int onion_len, int conversation, char* msg8_ptr, int msg8_len);
extern void c_PeerWithOnion(char* onion_ptr, int onion_len, char* handle8_ptr, int handle8_len);
extern char* c_SendMessage(char* onion_ptr, int onion_len, int conversation, char* msg9_ptr, int msg9_len);
extern char* c_GetMessageById(char* onion_ptr, int onion_len, int conversation, int message_id);
extern char* c_GetMessageByContentHash(char* onion_ptr, int onion_len, int conversation, char* contentHash9_ptr, int contentHash9_len);
extern char* c_GetMessageByContentHash(char* onion_ptr, int onion_len, int conversation, char* contentHash10_ptr, int contentHash10_len);
extern char* c_GetMessages(char* onion_ptr, int onion_len, int conversation, int index, int count);
extern char* c_SendInviteMessage(char* onion_ptr, int onion_len, int conversation, int target);
extern void c_UpdateMessageAttribute(char* onion_ptr, int onion_len, int conversation, int channel_id, int message_id, char* attributeKey10_ptr, int attributeKey10_len, char* attributeValue11_ptr, int attributeValue11_len);
extern void c_StartGroup(char* onion_ptr, int onion_len, char* name12_ptr, int name12_len, char* server13_ptr, int server13_len);
extern void c_DownloadFileDefaultLimit(char* onion_ptr, int onion_len, int conversation, char* filepath14_ptr, int filepath14_len, char* manifest15_ptr, int manifest15_len, char* filekey16_ptr, int filekey16_len);
extern void c_RestartFileShare(char* onion_ptr, int onion_len, char* filekey17_ptr, int filekey17_len);
extern void c_StopFileShare(char* onion_ptr, int onion_len, char* filekey18_ptr, int filekey18_len);
extern void c_CheckDownloadStatus(char* onion_ptr, int onion_len, char* filekey19_ptr, int filekey19_len);
extern void c_VerifyOrResumeDownload(char* onion_ptr, int onion_len, int conversation, char* filekey20_ptr, int filekey20_len);
extern char* c_ShareFile(char* onion_ptr, int onion_len, int conversation, char* filepath21_ptr, int filepath21_len);
extern void c_UpdateMessageAttribute(char* onion_ptr, int onion_len, int conversation, int channel_id, int message_id, char* attributeKey11_ptr, int attributeKey11_len, char* attributeValue12_ptr, int attributeValue12_len);
extern void c_StartGroup(char* onion_ptr, int onion_len, char* name13_ptr, int name13_len, char* server14_ptr, int server14_len);
extern void c_DownloadFileDefaultLimit(char* onion_ptr, int onion_len, int conversation, char* filepath15_ptr, int filepath15_len, char* manifest16_ptr, int manifest16_len, char* filekey17_ptr, int filekey17_len);
extern void c_RestartFileShare(char* onion_ptr, int onion_len, char* filekey18_ptr, int filekey18_len);
extern void c_StopFileShare(char* onion_ptr, int onion_len, char* filekey19_ptr, int filekey19_len);
extern void c_CheckDownloadStatus(char* onion_ptr, int onion_len, char* filekey20_ptr, int filekey20_len);
extern void c_VerifyOrResumeDownloadDefaultLimit(char* onion_ptr, int onion_len, int conversation, char* filekey21_ptr, int filekey21_len);
extern char* c_ShareFile(char* onion_ptr, int onion_len, int conversation, char* filepath22_ptr, int filepath22_len);
extern char* c_GetSharedFiles(char* onion_ptr, int onion_len, int conversation);
extern void c_CreateServer(char* password_ptr, int password_len, char* description22_ptr, int description22_len, char autostart23);
extern void c_SetServerAttribute(char* handle24_ptr, int handle24_len, char* key25_ptr, int key25_len, char* val26_ptr, int val26_len);
extern void c_CreateServer(char* password_ptr, int password_len, char* description23_ptr, int description23_len, char autostart24);
extern void c_SetServerAttribute(char* handle25_ptr, int handle25_len, char* key26_ptr, int key26_len, char* val27_ptr, int val27_len);
extern void c_LoadServers(char* password_ptr, int password_len);
extern void c_LaunchServers();
extern void c_LaunchServer(char* handle27_ptr, int handle27_len);
extern void c_StopServer(char* handle28_ptr, int handle28_len);
extern void c_LaunchServer(char* handle28_ptr, int handle28_len);
extern void c_StopServer(char* handle29_ptr, int handle29_len);
extern void c_StopServers();
extern void c_DestroyServers();
extern void c_DeleteServer(char* handle29_ptr, int handle29_len, char* password_ptr, int password_len);
extern void c_DeleteServer(char* handle30_ptr, int handle30_len, char* password_ptr, int password_len);
#ifdef __cplusplus
}

View File

@ -85,6 +85,7 @@ pub struct CwtchLibGo {}
// Some bindings are going to be wrapped so we can handle their returns and give most rust idiomatic returns (esp for json returning apis)
// so we pre define the real binding here as a _helper function and in the impl for CwtchLib define the wrapper
impl CwtchLibGo {
c_bind!(_peer_with(profile: &str, new_peer: &str;;) c_PeerWithOnion);
c_bind!(_update_settings(settings_json: &str;;) c_UpdateSettings);
c_bind!(_get_profile_attribute(profile: &str, key: &str;;) c_GetProfileAttribute -> String);
c_bind!(_get_conversation_attribute(profile: &str; conversation_id: i32; key: &str) c_GetConversationAttribute -> String);
@ -106,7 +107,7 @@ impl CwtchLibGo {
c_bind!(_stop_fileshare(profile: &str, file_key: &str;;) c_StopFileShare);
c_bind!(_download_file_default_limit(profile: &str; conversation_id: i32; file_path: &str, manifest_path: &str, file_key: &str) c_DownloadFileDefaultLimit);
c_bind!(_check_download_status(profile: &str, file_key: &str;;) c_CheckDownloadStatus);
c_bind!(_verify_or_resume_download(profile: &str; conversation_id: i32; file_key: &str) c_VerifyOrResumeDownload);
c_bind!(_verify_or_resume_download(profile: &str; conversation_id: i32; file_key: &str) c_VerifyOrResumeDownloadDefaultLimit);
c_bind!(_start_group(profile: &str, name: &str, server: &str;;) c_StartGroup);
c_bind!(_delete_profile(profile: &str, pass: &str;;) c_DeleteProfile);
c_bind!(_archive_conversation(profile: &str; conversation_id: i32;) c_ArchiveConversation);
@ -148,6 +149,11 @@ impl CwtchLib for CwtchLibGo {
fn accept_conversation(&self, profile: &ProfileIdentity, conversation_id: ConversationID) {
self._accept_conversation(profile.as_str(), conversation_id.into())
}
fn peer_with(&self, profile: &ProfileIdentity, new_peer_address: &str) {
self._peer_with(profile.as_str(), new_peer_address)
}
fn block_conversation(&self, profile: &ProfileIdentity, conversation_id: ConversationID) {
self._block_conversation(String::from(profile).as_str(), conversation_id.into())
}
@ -287,8 +293,8 @@ impl CwtchLib for CwtchLibGo {
fn set_server_attribute(&self, server: ServerIdentity, key: &str, val: &str) {
self._set_server_attribute(String::from(server).as_str(), key, val)
}
// todo: reenabled in 1.12
//c_bind!(get_debug_info(;;) c_GetDebugInfo -> String);
c_bind!(get_debug_info(;;) c_GetDebugInfo -> String);
fn get_appbus_event(&self) -> Event {
let event_json = self._get_appbus_event();

View File

@ -1,4 +1,4 @@
/* automatically generated by rust-bindgen 0.59.2 */
/* automatically generated by rust-bindgen 0.65.1 */
#[derive(PartialEq, Copy, Clone, Hash, Debug, Default)]
#[repr(C)]
@ -6,7 +6,6 @@ pub struct __BindgenComplex<T> {
pub re: T,
pub im: T,
}
pub type size_t = ::std::os::raw::c_ulong;
pub type wchar_t = ::std::os::raw::c_int;
#[repr(C)]
#[repr(align(16))]
@ -18,6 +17,8 @@ pub struct max_align_t {
}
#[test]
fn bindgen_test_layout_max_align_t() {
const UNINIT: ::std::mem::MaybeUninit<max_align_t> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<max_align_t>(),
32usize,
@ -29,9 +30,7 @@ fn bindgen_test_layout_max_align_t() {
concat!("Alignment of ", stringify!(max_align_t))
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<max_align_t>())).__clang_max_align_nonce1 as *const _ as usize
},
unsafe { ::std::ptr::addr_of!((*ptr).__clang_max_align_nonce1) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
@ -41,9 +40,7 @@ fn bindgen_test_layout_max_align_t() {
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<max_align_t>())).__clang_max_align_nonce2 as *const _ as usize
},
unsafe { ::std::ptr::addr_of!((*ptr).__clang_max_align_nonce2) as usize - ptr as usize },
16usize,
concat!(
"Offset of field: ",
@ -61,6 +58,8 @@ pub struct _GoString_ {
}
#[test]
fn bindgen_test_layout__GoString_() {
const UNINIT: ::std::mem::MaybeUninit<_GoString_> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<_GoString_>(),
16usize,
@ -72,7 +71,7 @@ fn bindgen_test_layout__GoString_() {
concat!("Alignment of ", stringify!(_GoString_))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<_GoString_>())).p as *const _ as usize },
unsafe { ::std::ptr::addr_of!((*ptr).p) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
@ -82,7 +81,7 @@ fn bindgen_test_layout__GoString_() {
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<_GoString_>())).n as *const _ as usize },
unsafe { ::std::ptr::addr_of!((*ptr).n) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
@ -102,7 +101,7 @@ pub type GoInt64 = ::std::os::raw::c_longlong;
pub type GoUint64 = ::std::os::raw::c_ulonglong;
pub type GoInt = GoInt64;
pub type GoUint = GoUint64;
pub type GoUintptr = size_t;
pub type GoUintptr = usize;
pub type GoFloat32 = f32;
pub type GoFloat64 = f64;
pub type GoComplex64 = __BindgenComplex<f32>;
@ -119,6 +118,8 @@ pub struct GoInterface {
}
#[test]
fn bindgen_test_layout_GoInterface() {
const UNINIT: ::std::mem::MaybeUninit<GoInterface> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<GoInterface>(),
16usize,
@ -130,7 +131,7 @@ fn bindgen_test_layout_GoInterface() {
concat!("Alignment of ", stringify!(GoInterface))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<GoInterface>())).t as *const _ as usize },
unsafe { ::std::ptr::addr_of!((*ptr).t) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
@ -140,7 +141,7 @@ fn bindgen_test_layout_GoInterface() {
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<GoInterface>())).v as *const _ as usize },
unsafe { ::std::ptr::addr_of!((*ptr).v) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
@ -159,6 +160,8 @@ pub struct GoSlice {
}
#[test]
fn bindgen_test_layout_GoSlice() {
const UNINIT: ::std::mem::MaybeUninit<GoSlice> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<GoSlice>(),
24usize,
@ -170,7 +173,7 @@ fn bindgen_test_layout_GoSlice() {
concat!("Alignment of ", stringify!(GoSlice))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<GoSlice>())).data as *const _ as usize },
unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
@ -180,7 +183,7 @@ fn bindgen_test_layout_GoSlice() {
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<GoSlice>())).len as *const _ as usize },
unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
@ -190,7 +193,7 @@ fn bindgen_test_layout_GoSlice() {
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<GoSlice>())).cap as *const _ as usize },
unsafe { ::std::ptr::addr_of!((*ptr).cap) as usize - ptr as usize },
16usize,
concat!(
"Offset of field: ",
@ -267,6 +270,9 @@ extern "C" {
extern "C" {
pub fn c_UpdateSettings(json_ptr: *mut ::std::os::raw::c_char, json_len: ::std::os::raw::c_int);
}
extern "C" {
pub fn c_GetDebugInfo() -> *mut ::std::os::raw::c_char;
}
extern "C" {
pub fn c_ActivatePeerEngine(
onion_ptr: *mut ::std::os::raw::c_char,
@ -373,13 +379,21 @@ extern "C" {
conversation: ::std::os::raw::c_int,
);
}
extern "C" {
pub fn c_PeerWithOnion(
onion_ptr: *mut ::std::os::raw::c_char,
onion_len: ::std::os::raw::c_int,
handle8_ptr: *mut ::std::os::raw::c_char,
handle8_len: ::std::os::raw::c_int,
);
}
extern "C" {
pub fn c_SendMessage(
onion_ptr: *mut ::std::os::raw::c_char,
onion_len: ::std::os::raw::c_int,
conversation: ::std::os::raw::c_int,
msg8_ptr: *mut ::std::os::raw::c_char,
msg8_len: ::std::os::raw::c_int,
msg9_ptr: *mut ::std::os::raw::c_char,
msg9_len: ::std::os::raw::c_int,
) -> *mut ::std::os::raw::c_char;
}
extern "C" {
@ -395,8 +409,8 @@ extern "C" {
onion_ptr: *mut ::std::os::raw::c_char,
onion_len: ::std::os::raw::c_int,
conversation: ::std::os::raw::c_int,
contentHash9_ptr: *mut ::std::os::raw::c_char,
contentHash9_len: ::std::os::raw::c_int,
contentHash10_ptr: *mut ::std::os::raw::c_char,
contentHash10_len: ::std::os::raw::c_int,
) -> *mut ::std::os::raw::c_char;
}
extern "C" {
@ -423,20 +437,20 @@ extern "C" {
conversation: ::std::os::raw::c_int,
channel_id: ::std::os::raw::c_int,
message_id: ::std::os::raw::c_int,
attributeKey10_ptr: *mut ::std::os::raw::c_char,
attributeKey10_len: ::std::os::raw::c_int,
attributeValue11_ptr: *mut ::std::os::raw::c_char,
attributeValue11_len: ::std::os::raw::c_int,
attributeKey11_ptr: *mut ::std::os::raw::c_char,
attributeKey11_len: ::std::os::raw::c_int,
attributeValue12_ptr: *mut ::std::os::raw::c_char,
attributeValue12_len: ::std::os::raw::c_int,
);
}
extern "C" {
pub fn c_StartGroup(
onion_ptr: *mut ::std::os::raw::c_char,
onion_len: ::std::os::raw::c_int,
name12_ptr: *mut ::std::os::raw::c_char,
name12_len: ::std::os::raw::c_int,
server13_ptr: *mut ::std::os::raw::c_char,
server13_len: ::std::os::raw::c_int,
name13_ptr: *mut ::std::os::raw::c_char,
name13_len: ::std::os::raw::c_int,
server14_ptr: *mut ::std::os::raw::c_char,
server14_len: ::std::os::raw::c_int,
);
}
extern "C" {
@ -444,24 +458,16 @@ extern "C" {
onion_ptr: *mut ::std::os::raw::c_char,
onion_len: ::std::os::raw::c_int,
conversation: ::std::os::raw::c_int,
filepath14_ptr: *mut ::std::os::raw::c_char,
filepath14_len: ::std::os::raw::c_int,
manifest15_ptr: *mut ::std::os::raw::c_char,
manifest15_len: ::std::os::raw::c_int,
filekey16_ptr: *mut ::std::os::raw::c_char,
filekey16_len: ::std::os::raw::c_int,
);
}
extern "C" {
pub fn c_RestartFileShare(
onion_ptr: *mut ::std::os::raw::c_char,
onion_len: ::std::os::raw::c_int,
filepath15_ptr: *mut ::std::os::raw::c_char,
filepath15_len: ::std::os::raw::c_int,
manifest16_ptr: *mut ::std::os::raw::c_char,
manifest16_len: ::std::os::raw::c_int,
filekey17_ptr: *mut ::std::os::raw::c_char,
filekey17_len: ::std::os::raw::c_int,
);
}
extern "C" {
pub fn c_StopFileShare(
pub fn c_RestartFileShare(
onion_ptr: *mut ::std::os::raw::c_char,
onion_len: ::std::os::raw::c_int,
filekey18_ptr: *mut ::std::os::raw::c_char,
@ -469,7 +475,7 @@ extern "C" {
);
}
extern "C" {
pub fn c_CheckDownloadStatus(
pub fn c_StopFileShare(
onion_ptr: *mut ::std::os::raw::c_char,
onion_len: ::std::os::raw::c_int,
filekey19_ptr: *mut ::std::os::raw::c_char,
@ -477,12 +483,20 @@ extern "C" {
);
}
extern "C" {
pub fn c_VerifyOrResumeDownload(
pub fn c_CheckDownloadStatus(
onion_ptr: *mut ::std::os::raw::c_char,
onion_len: ::std::os::raw::c_int,
filekey20_ptr: *mut ::std::os::raw::c_char,
filekey20_len: ::std::os::raw::c_int,
);
}
extern "C" {
pub fn c_VerifyOrResumeDownloadDefaultLimit(
onion_ptr: *mut ::std::os::raw::c_char,
onion_len: ::std::os::raw::c_int,
conversation: ::std::os::raw::c_int,
filekey20_ptr: *mut ::std::os::raw::c_char,
filekey20_len: ::std::os::raw::c_int,
filekey21_ptr: *mut ::std::os::raw::c_char,
filekey21_len: ::std::os::raw::c_int,
);
}
extern "C" {
@ -490,8 +504,8 @@ extern "C" {
onion_ptr: *mut ::std::os::raw::c_char,
onion_len: ::std::os::raw::c_int,
conversation: ::std::os::raw::c_int,
filepath21_ptr: *mut ::std::os::raw::c_char,
filepath21_len: ::std::os::raw::c_int,
filepath22_ptr: *mut ::std::os::raw::c_char,
filepath22_len: ::std::os::raw::c_int,
) -> *mut ::std::os::raw::c_char;
}
extern "C" {
@ -505,19 +519,19 @@ extern "C" {
pub fn c_CreateServer(
password_ptr: *mut ::std::os::raw::c_char,
password_len: ::std::os::raw::c_int,
description22_ptr: *mut ::std::os::raw::c_char,
description22_len: ::std::os::raw::c_int,
autostart23: ::std::os::raw::c_char,
description23_ptr: *mut ::std::os::raw::c_char,
description23_len: ::std::os::raw::c_int,
autostart24: ::std::os::raw::c_char,
);
}
extern "C" {
pub fn c_SetServerAttribute(
handle24_ptr: *mut ::std::os::raw::c_char,
handle24_len: ::std::os::raw::c_int,
key25_ptr: *mut ::std::os::raw::c_char,
key25_len: ::std::os::raw::c_int,
val26_ptr: *mut ::std::os::raw::c_char,
val26_len: ::std::os::raw::c_int,
handle25_ptr: *mut ::std::os::raw::c_char,
handle25_len: ::std::os::raw::c_int,
key26_ptr: *mut ::std::os::raw::c_char,
key26_len: ::std::os::raw::c_int,
val27_ptr: *mut ::std::os::raw::c_char,
val27_len: ::std::os::raw::c_int,
);
}
extern "C" {
@ -531,14 +545,14 @@ extern "C" {
}
extern "C" {
pub fn c_LaunchServer(
handle27_ptr: *mut ::std::os::raw::c_char,
handle27_len: ::std::os::raw::c_int,
handle28_ptr: *mut ::std::os::raw::c_char,
handle28_len: ::std::os::raw::c_int,
);
}
extern "C" {
pub fn c_StopServer(
handle28_ptr: *mut ::std::os::raw::c_char,
handle28_len: ::std::os::raw::c_int,
handle29_ptr: *mut ::std::os::raw::c_char,
handle29_len: ::std::os::raw::c_int,
);
}
extern "C" {
@ -549,8 +563,8 @@ extern "C" {
}
extern "C" {
pub fn c_DeleteServer(
handle29_ptr: *mut ::std::os::raw::c_char,
handle29_len: ::std::os::raw::c_int,
handle30_ptr: *mut ::std::os::raw::c_char,
handle30_len: ::std::os::raw::c_int,
password_ptr: *mut ::std::os::raw::c_char,
password_len: ::std::os::raw::c_int,
);

View File

@ -56,6 +56,9 @@ pub trait CwtchLib {
/// Cause profile to unblock conversation
fn unblock_conversation(&self, profile: &ProfileIdentity, conversation_id: ConversationID);
/// Attempt to peer with a a new peer
fn peer_with(&self, profile: &ProfileIdentity, new_peer_address: &str);
/// Get a specific message for a conversation by its id
fn get_message_by_id(&self, profile: &ProfileIdentity, conversation_id: ConversationID, message_id: i32) -> String;
@ -189,9 +192,8 @@ pub trait CwtchLib {
/// Set the specified server's attribute of key to val
fn set_server_attribute(&self, server: ServerIdentity, key: &str, val: &str);
// Get debug info (mem, goroutine stats) from lcg in json
// todo: reenable in 1.12
//fn get_debug_info(&self) -> String;
/// Get debug info (mem, goroutine stats) from lcg in json
fn get_debug_info(&self) -> String;
}
/// Create a new CwtchLib that is backed by bindings to libcwtch-go