Skip to main content

HavokSort

Trait HavokSort 

Source
pub trait HavokSort {
    type Error;

    // Required methods
    fn sort_for_bytes(&mut self) -> Result<(), Self::Error>;
    fn sort_for_xml(&mut self) -> Result<usize, Self::Error>;
    fn checked_sort_for_bytes(&mut self) -> Result<(), Self::Error>;
    fn checked_sort_for_xml(&mut self) -> Result<usize, Self::Error>;
}
Expand description

Trait that provides methods to sort classes for Havok binary/XML serialization.

Required Associated Types§

Required Methods§

Source

fn sort_for_bytes(&mut self) -> Result<(), Self::Error>

Sort classes by dependency order for binary serialization.

Binary HKX serialization requires class dependency pointers to be ordered from the root class, which is hkRootLevelContainer.

§Implementation details

This method assumes that the dependency graph is already valid and does not perform cycle detection for performance reasons.

  • Data deserialized from binary HKX by serde-hkx is already sorted.
  • XML data from the official Havok SDK requires sorting before binary serialization.

For a validated version, see HavokSort::checked_sort_for_bytes.

§Errors

Returns an error if the top pointer is missing.

Source

fn sort_for_xml(&mut self) -> Result<usize, Self::Error>

Sort classes by dependency order for XML serialization.

§Returns

The root pointer.

§Errors

Returns an error if the top pointer is missing.

§Implementation details

This method assumes that the dependency graph is already valid and does not perform cycle detection for performance reasons.

For a validated version, see HavokSort::checked_sort_for_xml.

Source

fn checked_sort_for_bytes(&mut self) -> Result<(), Self::Error>

Sort classes for binary serialization after validating the dependency graph.

This is equivalent to HavokSort::sort_for_bytes, but performs cycle detection before sorting.

Use this method when the input source is not guaranteed to have a valid HKX dependency graph.

§Errors

Returns [Error::CycleDetected] if a dependency cycle is detected.

A cyclic dependency graph cannot be deterministically serialized.

Source

fn checked_sort_for_xml(&mut self) -> Result<usize, Self::Error>

Sort classes for XML serialization after validating the dependency graph.

This is equivalent to HavokSort::sort_for_xml, but performs cycle detection before sorting.

Use this method when the input source is not guaranteed to have a valid HKX dependency graph.

§Returns

The root pointer.

§Errors

A cyclic dependency graph cannot be deterministically serialized.

Implementations on Foreign Types§

Source§

impl<V> HavokSort for IndexMap<usize, V>
where V: HavokClass,

Source§

type Error = Error

Source§

fn sort_for_bytes(&mut self) -> Result<(), Self::Error>

Source§

fn checked_sort_for_bytes(&mut self) -> Result<(), Self::Error>

Source§

fn sort_for_xml(&mut self) -> Result<usize, Self::Error>

Source§

fn checked_sort_for_xml(&mut self) -> Result<usize, Self::Error>

Implementors§