Expand description
§About
Arnelify® Server for Rust — a multi-language server with HTTP 3.0 and WebTransport support.
All supported protocols:
| # | Protocol | Transport |
|---|---|---|
| 1 | TCP1 | HTTP 1.1 |
| 2 | TCP1 | HTTP 2.0 |
| 3 | TCP1 | WebSocket |
| 4 | TCP2 | HTTP 3.0 |
| 5 | TCP2 | WebTransport |
§Minimal Requirements
Important: It’s strongly recommended to use in a container that has been built from the gcc v15.2.0 image.
- CPU: Apple M1 / Intel Core i7 / AMD Ryzen 7
- OS: Debian 11 / MacOS 15 / Windows 10 with WSL2.
- RAM: 4 GB
§Installation
Run in terminal:
cargo add arnelify_server§TCP2 / WebTransport
WebTransport - is a modern protocol for low-latency, bidirectional data transfer in browsers and applications. It works over Next Generation HTTP 3.0 and Next Generation TCP2 (QUIC), allowing multiple streams and messages in parallel.
§Configuration
| Option | Description |
|---|---|
| BLOCK_SIZE_KB | The size of the allocated memory used for processing large packets. |
| CERT_PEM | Path to the TLS cert-file in PEM format. |
| COMPRESSION | If this option is enabled, the server will use BROTLI compression if the client application supports it. This setting increases CPU resource consumption. The server will not use compression if the data size exceeds the value of BLOCK_SIZE_KB. |
| HANDSHAKE_TIMEOUT | Maximum time in seconds to complete the TLS handshake. |
| KEY_PEM | Path to the TLS private key-file in PEM format. |
| MAX_MESSAGE_SIZE_MB | Maximum size of a single message the server will accept from a client. |
| PING_TIMEOUT | Maximum time the server will wait for a ping from the client. |
| PORT | Defines which port the server will listen on. |
| SEND_TIMEOUT | Maximum time for the client to receive a response from the server. |
| THREAD_LIMIT | Defines the maximum number of threads that will handle requests. |
§Examples
use arnelify_server::tcp2::{
WebTransport, WebTransportBytes, WebTransportCtx, WebTransportHandler,
WebTransportLogger, WebTransportOpts, WebTransportStream,
};
use std::sync::{Arc, Mutex};
type JSON = serde_json::Value;
fn main() {
let wt_opts = WebTransportOpts {
block_size_kb: 64,
cert_pem: String::from("certs/cert.pem"),
compression: true,
handshake_timeout: 30,
key_pem: String::from("certs/key.pem"),
max_message_size_kb: 30,
ping_timeout: 30,
port: 4433,
send_timeout: 30,
thread_limit: 4,
};
let wt = WebTransport::new(wt_opts);
let wt_logger: Arc<WebTransportLogger> = Arc::new(
move |_level, message| {
println!("[Arnelify Server]: {}", message);
},
);
wt.logger(wt_logger);
let wt_handler: Arc<WebTransportHandler> = Arc::new(
move |ctx: Arc<Mutex<WebTransportCtx>>,
bytes: Arc<Mutex<WebTransportBytes>>,
stream: Arc<Mutex<WebTransportStream>>| {
let json: JSON = {
let ctx_lock = ctx.lock().unwrap();
ctx_lock.clone()
};
let bytes_vec = {
let bytes_lock = bytes.lock().unwrap();
bytes_lock.clone()
};
let mut stream_lock = stream.lock().unwrap();
stream_lock.push(&json, &bytes_vec);
stream_lock.close();
},
);
wt.on("connect", wt_handler);
wt.start();
}§TCP2 / HTTP 3.0
HTTP 3.0 - is the latest version of the HTTP protocol, built on top of Next Generation TCP2 (QUIC) instead of TCP1. It provides faster and more reliable connections by reducing handshake latency and improving packet loss recovery.
§Configuration
| Option | Description |
|---|---|
| ALLOW_EMPTY_FILES | If this option is enabled, the server will not reject empty files. |
| BLOCK_SIZE_KB | The size of the allocated memory used for processing large packets. |
| CERT_PEM | Path to the TLS cert-file in PEM format. |
| CHARSET | Defines the encoding that the server will recommend to all client applications. |
| COMPRESSION | If this option is enabled, the server will use BROTLI compression if the client application supports it. This setting increases CPU resource consumption. The server will not use compression if the data size exceeds the value of BLOCK_SIZE_KB. |
| KEEP_EXTENSIONS | If this option is enabled, file extensions will be preserved. |
| KEY_PEM | Path to the TLS private key-file in PEM format. |
| MAX_FIELDS | Defines the maximum number of fields in the received form. |
| MAX_FIELDS_SIZE_TOTAL_MB | Defines the maximum total size of all fields in the form. This option does not include file sizes. |
| MAX_FILES | Defines the maximum number of files in the form. |
| MAX_FILES_SIZE_TOTAL_MB | Defines the maximum total size of all files in the form. |
| MAX_FILE_SIZE_MB | Defines the maximum size of a single file in the form. |
| PORT | Defines which port the server will listen on. |
| STORAGE_PATH | Specifies the upload directory for storage. |
| THREAD_LIMIT | Defines the maximum number of threads that will handle requests. |
§Examples
use arnelify_server::tcp2::{
Http3, Http3Ctx, Http3Handler, Http3Logger, Http3Opts,
Http3Stream,
};
use std::sync::{Arc, Mutex};
type JSON = serde_json::Value;
fn main() {
let http3_opts = Http3Opts {
allow_empty_files: false,
block_size_kb: 64,
cert_pem: String::from("certs/cert.pem"),
charset: String::from("utf-8"),
compression: true,
keep_alive: 30,
keep_extensions: true,
key_pem: String::from("certs/key.pem"),
max_fields: 10,
max_fields_size_total_mb: 1,
max_files: 3,
max_files_size_total_mb: 60,
max_file_size_mb: 60,
port: 4433,
storage_path: String::from("/var/www/rs/storage"),
thread_limit: 4,
};
let http3 = Http3::new(http3_opts);
let http3_logger: Arc<Http3Logger> = Arc::new(
move |_level, message| {
println!("[Arnelify Server]: {}", message);
},
);
http3.logger(http3_logger);
let http3_handler: Arc<Http3Handler> = Arc::new(
move |ctx: Arc<Mutex<Http3Ctx>>,
stream: Arc<Mutex<Http3Stream>>| {
let json: JSON = {
let ctx_lock = ctx.lock().unwrap();
ctx_lock.clone()
};
let mut stream_lock = stream.lock().unwrap();
stream_lock.set_code(200);
stream_lock.push_json(&json, false);
stream_lock.end();
},
);
http3.on("/", http3_handler);
http3.start();
}§TCP1 / WebSocket
WebSocket - is a protocol that enables full-duplex, bidirectional communication between a client and server over a single TCP1 connection.
§Configuration
| Option | Description |
|---|---|
| BLOCK_SIZE_KB | The size of the allocated memory used for processing large packets. |
| COMPRESSION | If this option is enabled, the server will use BROTLI compression if the client application supports it. This setting increases CPU resource consumption. The server will not use compression if the data size exceeds the value of BLOCK_SIZE_KB. |
| HANDSHAKE_TIMEOUT | Maximum time in seconds to complete the TLS handshake. |
| MAX_MESSAGE_SIZE_MB | Maximum size of a single message the server will accept from a client. |
| PING_TIMEOUT | Maximum time the server will wait for a ping from the client. |
| PORT | Defines which port the server will listen on. |
| SEND_TIMEOUT | Maximum time for the client to receive a response from the server. |
| THREAD_LIMIT | Defines the maximum number of threads that will handle requests. |
§Examples
use arnelify_server::tcp1::{
WebSocket, WebSocketBytes, WebSocketCtx, WebSocketHandler,
WebSocketLogger, WebSocketOpts, WebSocketStream,
};
use std::sync::{Arc, Mutex};
type JSON = serde_json::Value;
fn main() {
let ws_opts = WebSocketOpts {
block_size_kb: 64,
compression: false,
handshake_timeout: 30,
max_message_size_kb: 30,
ping_timeout: 30,
port: 4433,
send_timeout: 30,
thread_limit: 4,
};
let ws = WebSocket::new(ws_opts);
let ws_logger: Arc<WebSocketLogger> = Arc::new(
move |_level, message| {
println!("[Arnelify Server]: {}", message);
},
);
ws.logger(ws_logger);
let ws_handler: Arc<WebSocketHandler> = Arc::new(
move |ctx: Arc<Mutex<WebSocketCtx>>,
bytes: Arc<Mutex<WebSocketBytes>>,
stream: Arc<Mutex<WebSocketStream>>| {
let json: JSON = {
let ctx_lock = ctx.lock().unwrap();
ctx_lock.clone()
};
let bytes_vec = {
let bytes_lock = bytes.lock().unwrap();
bytes_lock.clone()
};
let mut stream_lock = stream.lock().unwrap();
stream_lock.push(&json, &bytes_vec);
stream_lock.close();
},
);
ws.on("connect", ws_handler);
ws.start();
}§TCP1 / HTTP 2.0
HTTP 2.0 - is a revision of the HTTP protocol that improves performance over HTTP 1.1. It introduces multiplexed streams, allowing multiple requests and responses to be sent over a single TCP1 connection simultaneously.
§Configuration
| Option | Description |
|---|---|
| ALLOW_EMPTY_FILES | If this option is enabled, the server will not reject empty files. |
| BLOCK_SIZE_KB | The size of the allocated memory used for processing large packets. |
| CERT_PEM | Path to the TLS cert-file in PEM format. |
| CHARSET | Defines the encoding that the server will recommend to all client applications. |
| COMPRESSION | If this option is enabled, the server will use BROTLI compression if the client application supports it. This setting increases CPU resource consumption. The server will not use compression if the data size exceeds the value of BLOCK_SIZE_KB. |
| KEEP_EXTENSIONS | If this option is enabled, file extensions will be preserved. |
| KEY_PEM | Path to the TLS private key-file in PEM format. |
| MAX_FIELDS | Defines the maximum number of fields in the received form. |
| MAX_FIELDS_SIZE_TOTAL_MB | Defines the maximum total size of all fields in the form. This option does not include file sizes. |
| MAX_FILES | Defines the maximum number of files in the form. |
| MAX_FILES_SIZE_TOTAL_MB | Defines the maximum total size of all files in the form. |
| MAX_FILE_SIZE_MB | Defines the maximum size of a single file in the form. |
| PORT | Defines which port the server will listen on. |
| STORAGE_PATH | Specifies the upload directory for storage. |
| THREAD_LIMIT | Defines the maximum number of threads that will handle requests. |
§Examples
use arnelify_server::tcp1::{
Http2, Http2Ctx, Http2Handler, Http2Logger, Http2Opts,
Http2Stream,
};
use std::sync::{Arc, Mutex};
type JSON = serde_json::Value;
fn main() {
let http2_opts = Http2Opts {
allow_empty_files: false,
block_size_kb: 1024,
cert_pem: String::from("certs/cert.pem"),
charset: String::from("utf-8"),
compression: true,
keep_alive: 30,
keep_extensions: true,
key_pem: String::from("certs/key.pem"),
max_fields: 10,
max_fields_size_total_mb: 1,
max_files: 1,
max_files_size_total_mb: 10,
max_file_size_mb: 10,
port: 4433,
storage_path: String::from("/var/www/rs/storage"),
thread_limit: 4,
};
let http2 = Http2::new(http2_opts);
let http2_logger: Arc<Http2Logger> = Arc::new(
move |_level, message| {
println!("[Arnelify Server]: {}", message);
},
);
http2.logger(http2_logger);
let http2_handler: Arc<Http2Handler> = Arc::new(
move |ctx: Arc<Mutex<Http2Ctx>>,
stream: Arc<Mutex<Http2Stream>>| {
let json: JSON = {
let ctx_lock = ctx.lock().unwrap();
ctx_lock.clone()
};
let mut stream_lock = stream.lock().unwrap();
stream_lock.set_code(200);
stream_lock.push_json(&json, false);
stream_lock.end();
},
);
http2.on("/", http2_handler);
http2.start();
}§TCP1 / HTTP 1.1
HTTP 1.1 - is a widely used version of the HTTP protocol that relies on TCP1 connections for communication.
§Configuration
| Option | Description |
|---|---|
| ALLOW_EMPTY_FILES | If this option is enabled, the server will not reject empty files. |
| BLOCK_SIZE_KB | The size of the allocated memory used for processing large packets. |
| CHARSET | Defines the encoding that the server will recommend to all client applications. |
| COMPRESSION | If this option is enabled, the server will use BROTLI compression if the client application supports it. This setting increases CPU resource consumption. The server will not use compression if the data size exceeds the value of BLOCK_SIZE_KB. |
| KEEP_EXTENSIONS | If this option is enabled, file extensions will be preserved. |
| MAX_FIELDS | Defines the maximum number of fields in the received form. |
| MAX_FIELDS_SIZE_TOTAL_MB | Defines the maximum total size of all fields in the form. This option does not include file sizes. |
| MAX_FILES | Defines the maximum number of files in the form. |
| MAX_FILES_SIZE_TOTAL_MB | Defines the maximum total size of all files in the form. |
| MAX_FILE_SIZE_MB | Defines the maximum size of a single file in the form. |
| PORT | Defines which port the server will listen on. |
| STORAGE_PATH | Specifies the upload directory for storage. |
| THREAD_LIMIT | Defines the maximum number of threads that will handle requests. |
§Examples
use arnelify_server::tcp1::{
Http1, Http1Ctx, Http1Handler, Http1Logger, Http1Opts,
Http1Stream,
};
use std::sync::{Arc, Mutex};
type JSON = serde_json::Value;
fn main() {
let http1_opts = Http1Opts {
allow_empty_files: false,
block_size_kb: 64,
charset: String::from("utf-8"),
compression: true,
keep_alive: 30,
keep_extensions: true,
max_fields: 10,
max_fields_size_total_mb: 1,
max_files: 3,
max_files_size_total_mb: 60,
max_file_size_mb: 60,
port: 4433,
storage_path: String::from("/var/www/rs/storage"),
thread_limit: 4,
};
let http1 = Http1::new(http1_opts);
let http1_logger: Arc<Http1Logger> = Arc::new(move |_level, message| {
println!("[Arnelify Server]: {}", message);
});
http1.logger(http1_logger);
let http1_handler: Arc<Http1Handler> = Arc::new(
move |ctx: Arc<Mutex<Http1Ctx>>, stream: Arc<Mutex<Http1Stream>>| {
let json: JSON = {
let ctx_lock = ctx.lock().unwrap();
ctx_lock.clone()
};
let mut stream_lock = stream.lock().unwrap();
stream_lock.set_code(200);
stream_lock.push_json(&json, false);
stream_lock.end();
},
);
http1.on("/", http1_handler);
http1.start();
}§MIT License
This software is licensed under the MIT License. The original author’s name, logo, and the original name of the software must be included in all copies or substantial portions of the software.
§Contributing
Join us to help improve this software, fix bugs or implement new functionality. Active participation will help keep the software up-to-date, reliable, and aligned with the needs of its users.
Run in terminal:
docker compose up -d --build
docker ps
docker exec -it <CONTAINER ID> bashFor TCP2 / WebTransport:
cargo run --bin test_wtFor TCP2 / HTTP 3.0:
cargo run --bin test_http3For TCP1 / WebSocket:
cargo run --bin test_wsFor TCP1 / HTTP 2.0:
cargo run --bin test_http2For TCP1 / HTTP 1.1:
cargo run --bin test_http1§Release Notes
Version 0.9.4 — a multi-language server with HTTP 3.0 and WebTransport support.
We are excited to introduce the Arnelify Server for Rust! Please note that this version is raw and still in active development.
Change Log:
- Async Multi-Threading.
- Block processing in “on-the-fly” mode.
- BROTLI compression (still in development).
- FFI, PYO3 and NEON support.
- Significant refactoring and optimizations.
Please use this version with caution, as it may contain bugs and unfinished features. We are actively working on improving and expanding the server’s capabilities, and we welcome your feedback and suggestions.
§Links
Re-exports§
pub use tcp1::Http1;pub use tcp1::Http1Ctx;pub use tcp1::Http1Handler;pub use tcp1::Http1Logger;pub use tcp1::Http1Opts;pub use tcp1::Http1Stream;pub use tcp1::Http2;pub use tcp1::Http2Handler;pub use tcp1::Http2Logger;pub use tcp1::Http2Opts;pub use tcp1::Http2Stream;pub use tcp1::WebSocket;pub use tcp1::WebSocketBytes;pub use tcp1::WebSocketCtx;pub use tcp1::WebSocketHandler;pub use tcp1::WebSocketLogger;pub use tcp1::WebSocketOpts;pub use tcp1::WebSocketStream;pub use tcp2::Http3;pub use tcp2::Http3Handler;pub use tcp2::Http3Logger;pub use tcp2::Http3Opts;pub use tcp2::Http3Stream;pub use tcp2::WebTransport;pub use tcp2::WebTransportBytes;pub use tcp2::WebTransportCtx;pub use tcp2::WebTransportHandler;pub use tcp2::WebTransportLogger;pub use tcp2::WebTransportOpts;pub use tcp2::WebTransportStream;
Modules§
Enums§
Functions§
- http1_
add_ header - http1_
create - http1_
destroy - http1_
end - http1_
logger - http1_
on - http1_
push_ bytes - http1_
push_ file - http1_
push_ json - http1_
set_ code - http1_
set_ compression - http1_
set_ headers - http1_
start - http1_
stop - http2_
add_ header - http2_
create - http2_
destroy - http2_
end - http2_
logger - http2_
on - http2_
push_ bytes - http2_
push_ file - http2_
push_ json - http2_
set_ code - http2_
set_ compression - http2_
set_ headers - http2_
start - http2_
stop - http3_
add_ header - http3_
create - http3_
destroy - http3_
end - http3_
logger - http3_
on - http3_
push_ bytes - http3_
push_ file - http3_
push_ json - http3_
set_ code - http3_
set_ compression - http3_
set_ headers - http3_
start - http3_
stop - ws_
close - ws_
create - ws_
destroy - ws_
logger - ws_on
- ws_push
- ws_
push_ bytes - ws_
push_ json - ws_
start - ws_stop
- wt_
close - wt_
create - wt_
destroy - wt_
logger - wt_on
- wt_push
- wt_
push_ bytes - wt_
push_ json - wt_
start - wt_stop