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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! The Rust model of the ygopro data structures.
//!
//! This crate mirrors the types used by the original C++ ygopro and its core, so it is
//! the shared data layer for the Rust ports.
//!
//! # Modules
//!
//! - [`data`] — outside game data: cards, decks, limit lists, replays; and the
//! complicated structs inside messages: queries, responses.
//! - [`message`] — ygopro protocol messages (client-to-server, server-to-client) and
//! ygocore protocol messages (game message).
//! - [`constants`] — the constants and enums shared across the protocol
//! (players, locations, ...).
//! - `utils` — UTF-16 string helpers and the lazy [`Complex`](crate::complex::Complex)
//! message type.
//!
//! # Notes
//!
//! Some types and functions whose purpose is obvious from their name are left
//! undocumented.
//!
//! Most plain types are byte-for-byte identical to ygopro. However, the following types
//! have a memory layout that differs from their serialized layout:
//!
//! - [`UpdateData`](message::game_message::UpdateData) is a variable-length list read
//! until EOF; ygopro's unique layout makes it impossible to map soundly in safe Rust.
//! - Any type that uses a `Vec`: in memory a `Vec` is a pointer plus a length and a
//! capacity, while on the wire it is a contiguous byte stream. Examples:
//! [`SelectBattleCommand`](message::game_message::SelectBattleCommand).
//! - [`TypeChange`](message::server_to_client::TypeChange): differs because of
//! [`Netplayer`](crate::constants::Netplayer) change.
//! - [`Replay`](message::server_to_client::Replay): boxed because it is too large to
//! inline in the message enum.
//!
//! The following types differ noticeably because of design issues in the ygopro crate:
//!
//! - [`Netplayer`](constants::Netplayer), and consequently [`CorePlayer`](constants::CorePlayer).
//!
//! # Why [`binrw`](https://docs.rs/binrw) instead of [`serde`](https://docs.rs/serde)
//!
//! serde's data model does not fit ygopro's data types well, while binrw offers more
//! freedom — e.g. compressed formats like [`Replay`](crate::data::Replay) and streamed
//! structs like the query structs ([`CardPosition`](crate::data::CardPosition),
//! [`InfoLocation`](crate::data::InfoLocation)).
//!
pub use *;