Crates.io | async_uws |
lib.rs | async_uws |
version | 0.0.27 |
source | src |
created_at | 2023-09-25 16:03:01.271931 |
updated_at | 2024-11-21 17:17:47.916159 |
description | Rust async HTTP & WebSocket server based on uWebSockets |
homepage | https://github.com/GenrikhFetischev/async_uws |
repository | https://github.com/GenrikhFetischev/async_uws |
max_upload_size | |
id | 982856 |
size | 75,065 |
This server is built on top of uWebSockets
, leveraging tokio
for asynchronous runtime support. It is suitable for
Rust applications that require high-performance non-blocking I/O operations. If asynchronous programming is not a
requirement for your project, you may consider using a synchronous Rust server instead.
If you don't need tokio you might be interested
in libuwebsockets_rs - this is a zero-dependency rust library on
top of uWebSockets
with the same API as in original package.
To integrate uWebSockets
into your Rust application, you must ensure that several native libraries are correctly
linked to your binary. These libraries are libz
, libuv
, libssl
, libcrypto
, and the appropriate C++ standard
library for your system.
Configuration for build.rs
Your build.rs
script should link these libraries like so:
println!("cargo:rustc-link-lib=z");
println!("cargo:rustc-link-lib=uv");
println!("cargo:rustc-link-lib=ssl");
println!("cargo:rustc-link-lib=crypto");
// Conditional linking for C++ standard library based on the target OS
#[cfg(target_os = "macos")]
println!("cargo:rustc-link-lib=c++"); // Use libc++ for macOS
#[cfg(not(target_os = "macos"))]
println!("cargo:rustc-link-lib=stdc++"); // Use libstdc++ for other systems
On macOS, you might need to specify the include path and library path for the linker to find libuv
and libc++
. You
can do this by setting environment variables in your shell:
export LIBRARY_PATH="/opt/homebrew/lib:$LIBRARY_PATH"
export C_INCLUDE_PATH="/opt/homebrew/include:$C_INCLUDE_PATH"
export CPLUS_INCLUDE_PATH="/opt/homebrew/include:$CPLUS_INCLUDE_PATH"
Replace /opt/homebrew/lib
and /opt/homebrew/include
with the actual paths if libuv
is installed in a different
location on your system.
On Linux, ensure that libuv
, libssl
, and libcrypto
are installed via your distribution's package manager and that
the libstdc++
library is available on your system.
Unfortunately this library doesn't currently support Windows, but please don't hesitate sending a PR for Windows support at libuwebsockets-sys crate build script
If you encounter errors during compilation, such as missing header files (e.g., uv.h not found) or linking issues (e.g., library not found for -luv), here are some steps you can follow:
cargo build
.cargo clean
to remove any stale build outputs and then cargo build
to recompile the project.cargo build -vv
.If you encounter any issues or have improvements to suggest, please open an issue or a pull request in the repository. Your contributions are welcome to help make this project more robust and easier to use for the Rust community.