use std::io::Cursor; use anyhow::Result; use crate::{datatypes::{varint::VarInt, lenght_prefixed_string::LenghtPrefixedString}, packets::{Decode, Encode, Packet}}; #[derive(Debug)] pub struct HandshakePacket { pub protocal_version: VarInt, pub server_address: LenghtPrefixedString, pub server_port: u16, pub next_state: VarInt, } impl Decode for HandshakePacket { fn decode(cursor: &mut Cursor<&[u8]>) -> Result { let protocal_version = VarInt::decode(cursor)?; let server_address = LenghtPrefixedString::decode(cursor)?; let server_port = u16::decode(cursor)?; let next_state = VarInt::decode(cursor)?; Ok(HandshakePacket { protocal_version, server_address, server_port, next_state, }) } } impl Encode for HandshakePacket { fn encode(&self, buffer: &mut Vec) -> Result<()> { todo!() } } impl Packet for HandshakePacket { fn get_id(&self) -> i32 {0x00} }