Struct Trn

Source
pub struct Trn {
    pub file_type: FixedSizeString<4>,
    pub version_major: u16,
    pub version_minor: u16,
    pub packets: Vec<PacketData>,
}
Expand description

TRN file

Fields§

§file_type: FixedSizeString<4>

TRN file type (TRN, TRX)

§version_major: u16

TRN file version

§version_minor: u16

TRN file version

§packets: Vec<PacketData>

TRN packets

Implementations§

Source§

impl Trn

Source

pub fn from_bytes_head(input: &[u8]) -> NWNParseResult<'_, Self>

Parse the top of the TRN file, without loading / parsing all packets. Packets will be of type PacketData::Offset

Source

pub fn load_offsets( &mut self, buffer: &[u8], buffer_offset: u32, ) -> NWNParseResult<'_, ()>

Call PacketData::load_offset on all offset data (skipping non-offset packet data)

Source

pub fn parse_offsets( &mut self, buffer: &[u8], buffer_offset: u32, ) -> NWNParseResult<'_, ()>

Call PacketData::parse_offset on all offset data (skipping non-offset packet data)

Source

pub fn from_bytes(input: &[u8]) -> NWNParseResult<'_, Self>

Parse the entire TRN file and each of its packets. Packets will be of type PacketData::Parsed

Source

pub fn write_stream<T>(&self, output: &mut T) -> Result<(), Box<dyn Error>>
where T: Write + Seek,

Writes the content of the TRN file and its packets to a stream. Packets must be of type PacketData::Buffer or PacketData::Parsed.

Source

pub fn to_bytes(&self) -> Result<Vec<u8>, Box<dyn Error>>

Serialize the content of the TRN file and its packets to a buffer. Packets must be of type PacketData::Buffer or PacketData::Parsed.

Trait Implementations§

Source§

impl Debug for Trn

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Trn

§

impl RefUnwindSafe for Trn

§

impl Send for Trn

§

impl Sync for Trn

§

impl Unpin for Trn

§

impl UnwindSafe for Trn

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.