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§
Sourcefn sort_for_bytes(&mut self) -> Result<(), Self::Error>
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-hkxis 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.
Sourcefn sort_for_xml(&mut self) -> Result<usize, Self::Error>
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.
Sourcefn checked_sort_for_bytes(&mut self) -> Result<(), Self::Error>
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.
Sourcefn checked_sort_for_xml(&mut self) -> Result<usize, Self::Error>
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
- [
Error::CycleDetected] if a dependency cycle is detected. - Any error returned by
HavokSort::sort_for_xml.
A cyclic dependency graph cannot be deterministically serialized.