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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
pub
pub use ;
pub use AsciiString;
/// Derive macro for [`protocol::ProtocolRW`].
///
/// # Note
/// This macro makes few assumtions about the protocol enum:
/// - All packet must either have no fields or only one with a type that implements
/// [`protocol::PacketReadWrite`].
/// - Raw packet must either have no fields or only one with a [`Vec<u8>`] inside.
/// - Unknown packet must either have no fields or only one with a tuple of
/// ([`protocol::PacketHeader`], [`Vec<u8>`]) inside.
///
/// # Attribute explanation
/// - `#[Id(_id_, _subid_)]` sets the ID and subID of the packet variant.
/// - `#[Empty]` marks the variant as empty, i.e. it will always return an empty vec.
/// - `#[Raw]` marks the variant that will receive raw data if requested.
/// - `#[Unknown]` marks the variant that will receive unknown packets.
/// - `#[NGS]` marks the packet as NGS-only.
/// - `#[Classic]` marks the packet as classic only, i.e. non-NGS packet (Vita, JP, NA).
/// - `#[NA]` marks the packet as NA classic only.
/// - `#[JP]` marks the packet as JP classic only.
/// - `#[Vita]` marks the packet as Vita only.
/// - `#[Category(_category_)]` sets the category of all the packets following this attribute.
pub use ProtocolRW;
/// Derive macro for [`protocol::PacketReadWrite`].
///
/// # Note
/// This macro makes few assumtions about the packet struct:
/// - The only container type currently allowed is [`Vec<T>`].
/// - Any type that is not hardcoded (i.e integers, floats, [`half::f16`], [`std::net::Ipv4Addr`],
/// [`std::time::Duration`], [`String`], [`AsciiString`]) must implement
/// [`protocol::HelperReadWrite`] or have the `read`, `write` functions with the same prototype.
///
/// # Attribute explanation
/// ## Container attributes
/// - `#[Id(_id_, _subid_)]` sets the ID and subID of the packet.
/// - `#[Flags(_`[`protocol::Flags`]`_)]` sets the flags of the packet.
/// - `#[Magic(_xor_, _sub_)]`. If the `packed` flag is set, then this attribute sets the
/// deciphering xor and sub for variable length types.
/// ## Field attributes
/// - `#[Seek(_seek-amount_)]` sets the padding before the field data.
/// - `#[SeekAfter(_seek-amount_)]` sets the padding after the field data.
/// - `#[Const_u16(_const-int_)]` sets the constant u16 before the field data.
/// - `#[OnlyOn(_`[`protocol::PacketType`]`_)]`. If set then the field will only be read/written if
/// the reader packet type matches the specified packet type.
/// - `#[NotOn(_`[`protocol::PacketType`]`_)]`. If set then the field will only be read/written if
/// the reader packet type differs from the specified packet type.
pub use PacketRW;
/// Derive macro for [`protocol::HelperReadWrite`].
///
/// # Note
/// This macro makes few assumtions about
/// 1) the packet struct:
/// - Any type must implement [`protocol::HelperReadWrite`].
/// 2) the flags struct:
/// - All fields must be of type [`bool`]
/// 3) the variant enum:
/// - None of the fields must contain any data.
/// - `#[repr(_)]` must be set to an integer.
/// - Enum must implement [`Copy`].
///
/// # Attribute explanation
/// ## Container attributes
/// - `#[Flags(u*)]` makes the struct into a flags struct with the specified length.
/// - `#[BitFlags(u*)]` adds read/write support for [`bitflags`] flags containers.
/// ## Field attributes
/// - `#[Seek(_seek-amount_)]` sets the padding before the field data.
/// - `#[SeekAfter(_seek-amount_)]` sets the padding after the field data.
/// - `#[Const_u16(_const-int_)]` sets the constant u16 before the field data.
/// - `#[Read_default]` sets the default enum variant for reading.
/// - `#[Skip]`. If applied to a field struct field, then this attribute will skip one bit of the
/// flags.
/// - `#[ManualRW(_readfn_, _writefn_)]` sets the read/write functions for the variant. Specified
/// functions must have the same prototype as the [`protocol::HelperReadWrite`] functions.
/// - `#[OnlyOn(_`[`protocol::PacketType`]`_)]`. If set then the field will only be read/written if
/// the reader packet type matches the specified packet type.
/// - `#[NotOn(_`[`protocol::PacketType`]`_)]`. If set then the field will only be read/written if
/// the reader packet type differs from the specified packet type.
pub use HelperRW;