Trait convey_rs::ReadSaveFileBytes

source ·
pub trait ReadSaveFileBytes: ReadBytesExt + Seek {
Show 36 methods // Provided methods fn read_quaternion<E: ByteOrder>(&mut self) -> Result<Quaternion<f32>> { ... } fn read_quaternion_double<E: ByteOrder>( &mut self, ) -> Result<Quaternion<f64>> { ... } fn read_vector2d_double<E: ByteOrder>(&mut self) -> Result<Vector2D<f64>> { ... } fn read_vector2d_int<E: ByteOrder>(&mut self) -> Result<Vector2D<i32>> { ... } fn read_vector<E: ByteOrder>(&mut self) -> Result<Vector<f32>> { ... } fn read_vector_double<E: ByteOrder>(&mut self) -> Result<Vector<f64>> { ... } fn read_vector_int<E: ByteOrder>(&mut self) -> Result<Vector<i32>> { ... } fn read_vector4_double<E: ByteOrder>(&mut self) -> Result<Vector4<f64>> { ... } fn read_vector4_int<E: ByteOrder>(&mut self) -> Result<Vector4<i32>> { ... } fn read_color<E: ByteOrder>(&mut self) -> Result<Color<f32>> { ... } fn read_color_byte(&mut self) -> Result<Color<u8>> { ... } fn read_hex<E: ByteOrder>(&mut self, len: usize) -> Result<String> { ... } fn read_length_prefixed_string<E: ByteOrder>(&mut self) -> Result<String> { ... } fn seek_length_prefixed_string<E: ByteOrder>(&mut self) -> Result<()> { ... } fn read_header<E: ByteOrder>(&mut self) -> Result<Header> { ... } fn read_chunk<E: ByteOrder>(&mut self) -> Result<Vec<u8>> { ... } fn read_chunks<E: ByteOrder>( &mut self, stop_byte: u64, ) -> Result<Vec<Vec<u8>>> { ... } fn read_partitions<E: ByteOrder>(&mut self) -> Result<Partitions> { ... } fn read_object_reference<E: ByteOrder>( &mut self, object: &mut impl ObjectReferrable, map_name: &String, ) -> Result<()> { ... } fn read_component_header<E: ByteOrder>( &mut self, map_name: &String, ) -> Result<ComponentHeader> { ... } fn read_actor_header<E: ByteOrder>( &mut self, map_name: &String, ) -> Result<ActorHeader> { ... } fn read_level_object_header<E: ByteOrder>( &mut self, map_name: &String, ) -> Result<ObjectHeader> { ... } fn read_property_guid<E: ByteOrder>(&mut self) -> Result<Option<String>> { ... } fn read_fin_network_trace<E: ByteOrder>( &mut self, ) -> Result<FINNetworkTrace> { ... } fn read_fingput1_buffer_pixel<E: ByteOrder>( &mut self, ) -> Result<FINGPUT1BufferPixel> { ... } fn read_fin_lua_processor_state_storage<E: ByteOrder>( &mut self, header: &Header, parent_type: Option<&String>, ) -> Result<FINLuaProcessorStateStorage> { ... } fn read_array_property_struct<E: ByteOrder>( &mut self, num_elements: i32, header: &Header, ) -> Result<(ArrayPropertyStruct, Vec<ArrayPropertyStructValue>)> { ... } fn read_array_property<E: ByteOrder>( &mut self, property_name: &String, header: &Header, ) -> Result<ArrayProperty> { ... } fn read_map_property<E: ByteOrder>( &mut self, property_name: &String, parent_type: Option<&String>, header: &Header, ) -> Result<MapProperty> { ... } fn read_set_property<E: ByteOrder>( &mut self, parent_type: Option<&String>, header: &Header, ) -> Result<SetProperty> { ... } fn read_struct_property<E: ByteOrder>( &mut self, parent_type: Option<&String>, header: &Header, ) -> Result<(String, StructPropertyValue)> { ... } fn read_text_property<E: ByteOrder>( &mut self, build_version: i32, ) -> Result<TextProperty> { ... } fn read_property<E: ByteOrder>( &mut self, header: &Header, parent_type: Option<&String>, ) -> Result<Option<Property>> { ... } fn read_object<E: ByteOrder>( &mut self, object_header: &ObjectHeader, header: &Header, ) -> Result<Object> { ... } fn read_level<E: ByteOrder>( &mut self, level_index: i32, is_last_level: bool, header: &Header, ) -> Result<Level> { ... } fn read_levels<E: ByteOrder>( &mut self, header: &Header, ) -> Result<Vec<Level>> { ... }
}
Expand description

Extends byteorder’s ReadBytesExt (which itself extends io::Read) and io::Seek to build a robust byte reader with many great utility functions needed to support the custom save file format

Provided Methods§

source

fn read_quaternion<E: ByteOrder>(&mut self) -> Result<Quaternion<f32>>

Reads a quaternion with values as 32-bit floats

source

fn read_quaternion_double<E: ByteOrder>(&mut self) -> Result<Quaternion<f64>>

Reads a quaternion with values as 64-bit floats

source

fn read_vector2d_double<E: ByteOrder>(&mut self) -> Result<Vector2D<f64>>

Reads a 2D vector with values as 64-bit floats

source

fn read_vector2d_int<E: ByteOrder>(&mut self) -> Result<Vector2D<i32>>

Reads a 2D vector with values as 32-bit integers

source

fn read_vector<E: ByteOrder>(&mut self) -> Result<Vector<f32>>

Reads a 3D vector with values as 32-bit floats

source

fn read_vector_double<E: ByteOrder>(&mut self) -> Result<Vector<f64>>

Reads a 3D vector with values as 64-bit floats

source

fn read_vector_int<E: ByteOrder>(&mut self) -> Result<Vector<i32>>

Reads a 3D vector with values as 32-bit integers

source

fn read_vector4_double<E: ByteOrder>(&mut self) -> Result<Vector4<f64>>

Reads a 4D vector with values as 64-bit floats

source

fn read_vector4_int<E: ByteOrder>(&mut self) -> Result<Vector4<i32>>

Reads a 4D vector with values as 32-bit integers

source

fn read_color<E: ByteOrder>(&mut self) -> Result<Color<f32>>

Reads an RGB color with alpha channel with values as 32-bit floats

source

fn read_color_byte(&mut self) -> Result<Color<u8>>

Reads an RGB color with alpha channel with values as bytes

source

fn read_hex<E: ByteOrder>(&mut self, len: usize) -> Result<String>

Reads a specified number of bytes and attempts to parse them as a UTF-16 string

source

fn read_length_prefixed_string<E: ByteOrder>(&mut self) -> Result<String>

Reads a string whose length and encoding are specified by a prefixed byte:

  • If the length byte is > 0, the following string is UTF-8 encoded
  • If the length byte is < 0, the following string is UTF-16 encoded
  • If it == 0, the string is empty

The string is terminated by a null termination byte (/0) which is removed

source

fn seek_length_prefixed_string<E: ByteOrder>(&mut self) -> Result<()>

Similar to the above except the string is skipped over instead of parsed; used for unknown or redundant fields

source

fn read_header<E: ByteOrder>(&mut self) -> Result<Header>

Reads the file header; some of its fields, particularly the file version and the map name, are used to drive conditional parsing in other areas

source

fn read_chunk<E: ByteOrder>(&mut self) -> Result<Vec<u8>>

Reads a chunk header and its compressed body, performing some assertions on some fixed, well-known values

source

fn read_chunks<E: ByteOrder>(&mut self, stop_byte: u64) -> Result<Vec<Vec<u8>>>

Reads a chunk at a time until reaching the specified stop byte (which is the end of the file)

source

fn read_partitions<E: ByteOrder>(&mut self) -> Result<Partitions>

Reads the partition objects which start the main body and come before the level data

source

fn read_object_reference<E: ByteOrder>( &mut self, object: &mut impl ObjectReferrable, map_name: &String, ) -> Result<()>

Given a type which implements ObjectReferrable, reads a level name and a path name and sets one or both on the given object

NOTE: Mutates the given object

source

fn read_component_header<E: ByteOrder>( &mut self, map_name: &String, ) -> Result<ComponentHeader>

Reads an object of type Component’s header

source

fn read_actor_header<E: ByteOrder>( &mut self, map_name: &String, ) -> Result<ActorHeader>

Reads an object of type Actor’s header

source

fn read_level_object_header<E: ByteOrder>( &mut self, map_name: &String, ) -> Result<ObjectHeader>

Reads an object header for a level object by reading a 32-bit integer to determine the header type and then calling the corresponding function

source

fn read_property_guid<E: ByteOrder>(&mut self) -> Result<Option<String>>

Reads a byte flag to determine if the following 16 bytes will be a hex-represented GUID

source

fn read_fin_network_trace<E: ByteOrder>(&mut self) -> Result<FINNetworkTrace>

source

fn read_fingput1_buffer_pixel<E: ByteOrder>( &mut self, ) -> Result<FINGPUT1BufferPixel>

source

fn read_fin_lua_processor_state_storage<E: ByteOrder>( &mut self, header: &Header, parent_type: Option<&String>, ) -> Result<FINLuaProcessorStateStorage>

source

fn read_array_property_struct<E: ByteOrder>( &mut self, num_elements: i32, header: &Header, ) -> Result<(ArrayPropertyStruct, Vec<ArrayPropertyStructValue>)>

Reads an array property whose element is of type struct

source

fn read_array_property<E: ByteOrder>( &mut self, property_name: &String, header: &Header, ) -> Result<ArrayProperty>

Reads an array property

source

fn read_map_property<E: ByteOrder>( &mut self, property_name: &String, parent_type: Option<&String>, header: &Header, ) -> Result<MapProperty>

Reads a map property

source

fn read_set_property<E: ByteOrder>( &mut self, parent_type: Option<&String>, header: &Header, ) -> Result<SetProperty>

Reads a set property

source

fn read_struct_property<E: ByteOrder>( &mut self, parent_type: Option<&String>, header: &Header, ) -> Result<(String, StructPropertyValue)>

Reads a struct property

source

fn read_text_property<E: ByteOrder>( &mut self, build_version: i32, ) -> Result<TextProperty>

Reads a text property

source

fn read_property<E: ByteOrder>( &mut self, header: &Header, parent_type: Option<&String>, ) -> Result<Option<Property>>

Reads a property

source

fn read_object<E: ByteOrder>( &mut self, object_header: &ObjectHeader, header: &Header, ) -> Result<Object>

Reads an object by reading its meta followed by its properties and validating its supposed size against actual size and seeking past any gap

source

fn read_level<E: ByteOrder>( &mut self, level_index: i32, is_last_level: bool, header: &Header, ) -> Result<Level>

Reads a single level by reading its name, object headers, collectables, objects, and seeking past a repeated set of collectables if set

source

fn read_levels<E: ByteOrder>(&mut self, header: &Header) -> Result<Vec<Level>>

Reads a 32-bit integer to determine the number of levels present and then reads each level one-by-one

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<R: Read + Seek> ReadSaveFileBytes for R

Auto-implements the above trait for all types which also implement both io::Read and io::Seek