Crates.io | rastdp |
lib.rs | rastdp |
version | |
source | src |
created_at | 2025-01-05 21:40:27.423953 |
updated_at | 2025-01-08 22:55:32.578023 |
description | Rastdp (Rasterized Datagram Protocol) is an asynchronous communication protocol built on UDP for efficient inter-application messaging. |
homepage | |
repository | https://github.com/milen-denev/rastdp |
max_upload_size | |
id | 1505073 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Rastdp is ideal for low-latency networking environments, enabling rapid data exchange and seamless communication in scenarios where performance and scalability are critica
The network byte layout is currently not stable and is subject to change. A detailed paper on the finalized layout will be published to allow third-party integration.
Short answer, no. It will get through many refinements and even changes to the table files. Until version 1.0.0 use it on your own risk.
[dependencies]
tokio = { version = "1", features = ["full"] }
async-lazy = { version = "0.1.0", features = ["parking_lot"] }
use rastdp::{receiver::Receiver, sender::Sender};
use tokio::io;
use std::sync::Arc;
//Static receiver
static RECEIVER: async_lazy::Lazy<Arc<Receiver>> = async_lazy::Lazy::const_new(|| Box::pin(async {
let receiver = Receiver::new("127.0.0.1:8080").await.unwrap();
Arc::new(receiver)
}));
static SENDER: async_lazy::Lazy<Arc<Sender>> = async_lazy::Lazy::const_new(|| Box::pin(async {
let sender = Sender::new("127.0.0.1:8080".to_string()).await.unwrap();
Arc::new(sender)
}));
#[tokio::main]
async fn main() -> io::Result<()> {
// Server processing requests
tokio::spawn(async {
let receiver = RECEIVER.force().await;
let receiver_clone = receiver.clone();
// Function that returns a result
receiver_clone.start_processing_function_result(
a_function_receiving_request_and_returning_result
).await;
// Function that only processes requests
receiver.start_processing_function(
a_function_receiving_request
).await;
});
// Client sending requests
let sender = SENDER.force().await;
for i in 0..1_000_000 {
tokio::spawn(async {
let sender_clone = sender.clone();
let test = sender_clone.send_message_get_reply("Hello, world!".repeat(10).as_bytes()).await;
println!("test: {:?}", test);
});
}
loop {
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
}
}
async fn a_function_receiving_request_and_returning_result(buf: Vec<u8>) -> Vec<u8> {
println!("buf: {:?}", buf.len());
vec![1, 2, 3, 4, 5]
}
async fn a_function_receiving_request(buf: Vec<u8>) {
println!("buf: {:?}", buf.len());
}
Everything in this directory is distributed under GNU GENERAL PUBLIC LICENSE version 3.