bancho-packets-5.0.1 has been yanked.
bancho-packets
osu! bancho packet Reading & Writing library.
docs https://docs.rs/bancho-packets
Usage
Add to your cargo.toml
[]
= "4"
Or run the following Cargo command in your project directory:
Examples
see more: examples, src/tests.rs
Reading packets
use *;
// Packets from osu! bancho
let data = &;
// Create reader
let reader = new;
// Read packets
for packet in reader
/* Results
packet id: OSU_PING: Non-payload
packet id: BANCHO_NOTIFICATION: payload: Some("Hello, World!💖")
packet id: OSU_PING: Non-payload
packet id: BANCHO_NOTIFICATION: payload: Some("哈哈【😃】")
packet id: BANCHO_ACCOUNT_RESTRICTED: Non-payload
packet id: BANCHO_NOTIFICATION: payload: Some("读取完了!!✨")
*/
Writing packets
use *;
// Single packet
let login_reply_from_server = pack;
let serverside_notification = pack;
// Multiple packets with Builder
let packets = new
.add
.add
.add
.add
.add
.add
.build;
Build your own packet
use *;
// Build simple packet
let number_data: i32 = 1;
let packet = packet!
// Complex (old)
// Complex (new)
packet_struct!;
// Complex (new)
packet_struct!;
Available attributies
ReadPacket: This derive macro will implement theBanchoPacketReadtrait for the struct.WritePacket: This derive macro will implement theBanchoPacketReadtrait for the struct.PacketLength: This derive macro will implement theBanchoPacketLengthtrait for the struct.
example
use ;
/// [`BanchoMessage`] is the message structure of the bancho client.
// Now we can use [`PayloadReader`] to read the [`BanchoMessage`] from bytes.
let mut reader = new;
let packet = reader.next.unwrap;
let mut payload_reader = new;
let message = payload_reader.;
println!;
Run Test
cargo test
Run Benchmark
cargo bench