Crates.io | minecrevy_io |
lib.rs | minecrevy_io |
version | 0.1.0 |
source | src |
created_at | 2023-12-09 02:58:14.622457 |
updated_at | 2023-12-09 02:58:14.622457 |
description | A library for reading and writing Minecraft protocol types. |
homepage | https://github.com/Minecrevy/minecrevy |
repository | https://github.com/Minecrevy/minecrevy |
max_upload_size | |
id | 1063259 |
size | 49,752 |
A library for reading and writing Minecraft protocol types.
use std::io;
use minecrevy_io::{
args::{IntArgs, StringArgs},
McRead,
};
#[derive(Clone, PartialEq, Debug)]
pub struct Handshake {
pub protocol_version: i32,
pub server_address: String,
pub server_port: u16,
pub next_state: i32,
}
impl McRead for Handshake {
type Args = ();
fn read(mut reader: impl io::Read, (): Self::Args) -> io::Result<Self> {
Ok(Self {
protocol_version: i32::read(&mut reader, IntArgs { varint: true })?,
server_address: String::read(&mut reader, StringArgs { max_len: Some(255) })?,
server_port: u16::read(&mut reader, ())?,
next_state: i32::read(&mut reader, IntArgs { varint: true })?,
})
}
}