aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/packets/login/s_hello.rs
blob: 075cd99ce132a701707f8acaeaad90116f681446 (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
28
29
30
31
use azalea_buf::AzBuf;
use azalea_protocol_macros::ServerboundLoginPacket;
use uuid::Uuid;

#[derive(AzBuf, Clone, Debug, Eq, PartialEq, ServerboundLoginPacket)]
pub struct ServerboundHello {
    #[limit(16)]
    pub name: String,
    pub profile_id: Uuid,
}

#[cfg(test)]
mod tests {
    use std::io::Cursor;

    use azalea_buf::AzBuf;

    use super::*;

    #[test]
    fn test_read_write() {
        let packet = ServerboundHello {
            name: "test".to_owned(),
            profile_id: Uuid::nil(),
        };
        let mut buf: Vec<u8> = Vec::new();
        packet.azalea_write(&mut buf).unwrap();
        let packet2 = ServerboundHello::azalea_read(&mut Cursor::new(&buf)).unwrap();
        assert_eq!(packet, packet2);
    }
}