minecrevy_io

Crates.iominecrevy_io
lib.rsminecrevy_io
version0.1.0
sourcesrc
created_at2023-12-09 02:58:14.622457
updated_at2023-12-09 02:58:14.622457
descriptionA library for reading and writing Minecraft protocol types.
homepagehttps://github.com/Minecrevy/minecrevy
repositoryhttps://github.com/Minecrevy/minecrevy
max_upload_size
id1063259
size49,752
Christian Hughes (ItsDoot)

documentation

README

minecrevy_io

A library for reading and writing Minecraft protocol types.

Example without derive

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 })?,
        })
    }
}
Commit count: 13

cargo fmt