pub enum PacketData {
Parsed(Box<Packet>),
Buffer {
packet_type: PacketType,
data: Vec<u8>,
},
Offset {
packet_type: PacketType,
offset: u32,
},
}Expand description
TRN packet data, that may or may not be loaded in memory or parsed
Variants§
Parsed(Box<Packet>)
Packet data has been fully loaded and parsed
Buffer
Packet data has been loaded in memory, but not parsed
Fields
packet_type: PacketTypePacket type
Offset
Unloaded packet. The packet has not been parsed nor loaded in memory.
Fields
packet_type: PacketTypeExpected packet type. Packet data block may indicate a different type.
Implementations§
Source§impl PacketData
impl PacketData
Sourcepub fn get_type(&self) -> PacketType
pub fn get_type(&self) -> PacketType
Returns the packet type, regardless of whether it has been parsed or not
Sourcepub fn from_bytes_parse(
input: &[u8],
expected_packet_type: Option<PacketType>,
) -> NWNParseResult<'_, Self>
pub fn from_bytes_parse( input: &[u8], expected_packet_type: Option<PacketType>, ) -> NWNParseResult<'_, Self>
Parse a packet data block, including its type and size header. Returns a PacketData::Parsed
Sourcepub fn from_bytes_clone(
input: &[u8],
expected_packet_type: Option<PacketType>,
) -> NWNParseResult<'_, Self>
pub fn from_bytes_clone( input: &[u8], expected_packet_type: Option<PacketType>, ) -> NWNParseResult<'_, Self>
Store packet data without parsing its content. Returns a PacketData::Buffer
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Returns the serialized data block for the packet, with the type and size header
Sourcepub fn load_offset(
&mut self,
buffer: &[u8],
buffer_offset: u32,
) -> NWNParseResult<'_, &[u8]>
pub fn load_offset( &mut self, buffer: &[u8], buffer_offset: u32, ) -> NWNParseResult<'_, &[u8]>
Converts self from a PacketData::Offset into a PacketData::Buffer
Sourcepub fn parse_offset(
&mut self,
buffer: &[u8],
buffer_offset: u32,
) -> NWNParseResult<'_, ()>
pub fn parse_offset( &mut self, buffer: &[u8], buffer_offset: u32, ) -> NWNParseResult<'_, ()>
Converts self from a PacketData::Offset into a PacketData::Parsed
Sourcepub fn parse_buffer(&mut self) -> NWNParseResult<'_, ()>
pub fn parse_buffer(&mut self) -> NWNParseResult<'_, ()>
Converts self from a PacketData::Buffer into a PacketData::Parsed