Prc

Trait Prc 

Source
pub trait Prc: Sized {
    // Required method
    fn read_param<R: Read + Seek>(
        reader: &mut R,
        offsets: FileOffsets,
    ) -> Result<Self>;

    // Provided methods
    fn read_from_struct<R: Read + Seek>(
        reader: &mut R,
        hash: Hash40,
        offsets: FileOffsets,
        struct_data: StructData,
    ) -> Result<Self> { ... }
    fn read_file<R: Read + Seek>(reader: &mut R) -> Result<Self> { ... }
}
Expand description

A trait allowing a type to be converted from the param container format

Required Methods§

Source

fn read_param<R: Read + Seek>( reader: &mut R, offsets: FileOffsets, ) -> Result<Self>

Creates Self by reading the from the data. The reader should be positioned at the start of the param marker before calling this

Provided Methods§

Source

fn read_from_struct<R: Read + Seek>( reader: &mut R, hash: Hash40, offsets: FileOffsets, struct_data: StructData, ) -> Result<Self>

Controls how structs should try to behave when reading the param. Implementing this manually is usually not necessary, but it can be useful in certain cases. For example, Option types work by returning None when the hash isn’t found in the struct.

Source

fn read_file<R: Read + Seek>(reader: &mut R) -> Result<Self>

A blanket implementation which reads the entire file to create Self. The reader should be at the beginning of the file before calling this.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Prc for bool

Source§

fn read_param<R: Read + Seek>( reader: &mut R, _offsets: FileOffsets, ) -> Result<Self>

Source§

impl Prc for f32

Source§

fn read_param<R: Read + Seek>( reader: &mut R, _offsets: FileOffsets, ) -> Result<Self>

Source§

impl Prc for i8

Source§

fn read_param<R: Read + Seek>( reader: &mut R, _offsets: FileOffsets, ) -> Result<Self>

Source§

impl Prc for i16

Source§

fn read_param<R: Read + Seek>( reader: &mut R, _offsets: FileOffsets, ) -> Result<Self>

Source§

impl Prc for i32

Source§

fn read_param<R: Read + Seek>( reader: &mut R, _offsets: FileOffsets, ) -> Result<Self>

Source§

impl Prc for u8

Source§

fn read_param<R: Read + Seek>( reader: &mut R, _offsets: FileOffsets, ) -> Result<Self>

Source§

impl Prc for u16

Source§

fn read_param<R: Read + Seek>( reader: &mut R, _offsets: FileOffsets, ) -> Result<Self>

Source§

impl Prc for u32

Source§

fn read_param<R: Read + Seek>( reader: &mut R, _offsets: FileOffsets, ) -> Result<Self>

Source§

impl Prc for String

Source§

fn read_param<R: Read + Seek>( reader: &mut R, offsets: FileOffsets, ) -> Result<Self>

Source§

impl Prc for Hash40

Source§

fn read_param<R: Read + Seek>( reader: &mut R, offsets: FileOffsets, ) -> Result<Self>

Source§

impl<T: Prc> Prc for Option<T>

Source§

fn read_param<R: Read + Seek>(_: &mut R, _: FileOffsets) -> Result<Self>

Source§

fn read_from_struct<R: Read + Seek>( reader: &mut R, hash: Hash40, offsets: FileOffsets, struct_data: StructData, ) -> Result<Self>

Source§

impl<T: Prc> Prc for Vec<T>

Source§

fn read_param<R: Read + Seek>( reader: &mut R, offsets: FileOffsets, ) -> Result<Self>

Implementors§