aboutsummaryrefslogtreecommitdiff
path: root/minecraft-protocol/src/packets/login/serverbound_hello_packet.rs
blob: 69448074b1fbc6c24c42c3e5af26ab50b4cc64c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use std::hash::Hash;
use tokio::io::BufReader;

use crate::mc_buf;

use super::LoginPacket;

#[derive(Hash, Clone, Debug)]
pub struct ServerboundHelloPacket {
    pub username: String,
}

impl ServerboundHelloPacket {
    pub fn get(self) -> LoginPacket {
        LoginPacket::ServerboundHelloPacket(self)
    }

    pub fn write(&self, buf: &mut Vec<u8>) {
        mc_buf::write_utf(buf, &self.username);
    }

    pub async fn read<T: tokio::io::AsyncRead + std::marker::Unpin + std::marker::Send>(
        _buf: &mut BufReader<T>,
    ) -> Result<LoginPacket, String> {
        Err("ServerboundHelloPacket::read not implemented".to_string())
    }
}