tox-rs / rstox Goto Github PK
View Code? Open in Web Editor NEWRust bindings to c-toxcore
License: GNU General Public License v3.0
Rust bindings to c-toxcore
License: GNU General Public License v3.0
e.g.
let mut name: Vec<u8> = Vec::with_capacity(size);
tox_try!(err, ll::tox_conference_peer_get_name(
self.raw,
conference_number,
peer_number,
name.as_mut_ptr(),
err.as_mut_ptr()
));
Ok(String::from_utf8_unchecked(name))
The resulting string is always empty. I've confirmed that the toxcore functions succeed, but for whatever reason the result never gets copied to the vector.
My proposed fix would be to change all such instances to:
let mut name = MaybeUninit::<[u8; MAX_NAME_LENGTH]>::uninit();
tox_try!(err, ll::tox_conference_peer_get_name(
self.raw,
conference_number,
peer_number,
name.as_mut_ptr() as *mut u8,
err.as_mut_ptr()
));
Ok(String::from_utf8_lossy(&mut name.assume_init()[..size].to_string()))
However, this looks ugly to me. I'm not sure if it's safe or the proper solution.
This would be useful and you'll have to do it eventually. You can just put it in a different branch. The API is here https://github.com/JFreegman/toxcore/blob/new_groupchats/toxcore/tox.h#L781-L1080
There are no tests here. Add tests :).
For test coverage instructions, see https://users.rust-lang.org/t/tutorial-how-to-collect-test-coverages-for-rust-project/650/2.
In https://github.com/TokTok/c-toxcore we have made old group chats a first class supported API and rebranded it as conference. The new group chats will be called "group". We have also removed user data from callback registration functions. This now needs to be passed to tox_iterate.
So, you can remove the "KLUDGE" comments and use the proper API now.
When using the irungentoo/new branch, profile saving/loading doesn't work. When printing out Tox_Options values at the start of tox_new() I get some strange output. Data length is always zero, the data pointer is always non-null, and the data type is some very large number like 751087616. Everything looks normal before going through rstox. I don't have the time to investigate this further at the moment.
thread 'main' panicked at 'attempted to leave type
core::errors::InitError uninitialized, which is invalid', /rustc/04488afe34512aa4c33566eb16d8c912a3ae04f9/src/libcore/mem/mod.rs:664:9
I create a new cargo project
cargo new project --bin
Then I add the line to my Cargo.toml
[dependencies.rstox] git = "https://github.com/suhr/rstox.git"
I also confirmed that libtoxcore and libtoxav are in my /user/local/lib
Get the following error when trying to build
error: linking with `cc` failed: exit code: 1
note: "cc" "-m64" "-L" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib" "/Users/cvu/Github/demo/RustChat/target/debug/RustChat.0.o" "-o" "/Users/cvu/Github/demo/RustChat/target/debug/RustChat" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/cvu/Github/demo/RustChat/target/debug" "-L" "/Users/cvu/Github/demo/RustChat/target/debug/deps" "-L" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib" "-L" "/Users/cvu/Github/demo/RustChat/.rust/lib/x86_64-apple-darwin" "-L" "/Users/cvu/Github/demo/RustChat/lib/x86_64-apple-darwin" "/Users/cvu/Github/demo/RustChat/target/debug/deps/librstox-ab1806e399b3d68b.rlib" "/Users/cvu/Github/demo/RustChat/target/debug/deps/liblibc-f654c8036439f8ef.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libstd-71b07a99.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libcollections-71b07a99.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/librustc_unicode-71b07a99.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/librand-71b07a99.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/liballoc-71b07a99.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/liballoc_jemalloc-71b07a99.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/liblibc-71b07a99.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libcore-71b07a99.rlib" "-l" "toxcore" "-l" "toxav" "-l" "System" "-l" "pthread" "-l" "c" "-l" "m" "-l" "compiler-rt"
note: ld: warning: directory not found for option '-L/Users/cvu/Github/demo/RustChat/.rust/lib/x86_64-apple-darwin'
ld: warning: directory not found for option '-L/Users/cvu/Github/demo/RustChat/lib/x86_64-apple-darwin'
ld: library not found for -ltoxcore
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Please add custom packet support. (send_lossless_packet and the others)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.