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
32
33
34
35
36
37
38
39
40
41
//! Networking — mods' packets over named channels, as Yog Data.
//!
//! A packet's payload is bytes; a typed packet is any [`Schema`] type, sent
//! and read the way everything else Yog sends is (`yog_data::to_bytes` /
//! `read_bytes`). NBT is only ever built when something must be handed to
//! the game itself.
//!
//! ```
//! use yog_data::Schema;
//! use yog_network::Packet;
//!
//! #[derive(Schema, Debug, PartialEq)]
//! pub struct Teleport {
//! x: f64,
//! y: f64,
//! z: f64,
//! player: String,
//! }
//!
//! let pkt = Teleport { x: 0.0, y: 64.0, z: 0.0, player: "Steve".into() };
//! assert_eq!(Teleport::from_payload(&pkt.to_payload()), Some(pkt));
//! ```
use Schema;
/// A packet's payload as bytes and back — every [`Schema`] type is one.