fbxcel/writer/v7400/binary/footer.rs
1//! FBX footer.
2
3/// FBX footer padding length.
4#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
5pub enum FbxFooterPaddingLength {
6 /// Default (correct) value.
7 Default,
8 /// Forced specified value, which can be wrong.
9 Forced(u8),
10}
11
12impl Default for FbxFooterPaddingLength {
13 #[inline]
14 fn default() -> Self {
15 FbxFooterPaddingLength::Default
16 }
17}
18
19/// FBX 7.4 footer.
20#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
21pub struct FbxFooter<'a> {
22 /// Unknown (semirandom) 16-bytes data.
23 ///
24 /// This field is expected to have prescribed upper 4 bits, i.e. the field
25 /// is `fx bx ax 0x dx cx dx 6x bx 7x fx 8x 1x fx 2x 7x` if the FBX data is
26 /// exported from official SDK.
27 ///
28 /// Note that third party exporter will use completely random data.
29 pub unknown1: Option<&'a [u8; 16]>,
30 /// Padding length.
31 ///
32 /// Padding is `padding_len` `0`s.
33 /// `padding_len >= 0 && padding <= 15` should hold.
34 ///
35 /// Note that third party exporter will not use correct padding length.
36 pub padding_len: FbxFooterPaddingLength,
37 /// Unknown 4-bytes data.
38 ///
39 /// This is expected to be `[0u8; 4]`.
40 pub unknown2: Option<[u8; 4]>,
41 /// Unknown 16-bytes data.
42 ///
43 /// This is expected to be `[0xf8, 0x5a, 0x8c, 0x6a, 0xde, 0xf5, 0xd9, 0x7e,
44 /// 0xec, 0xe9, 0x0c, 0xe3, 0x75, 0x8f, 0x29, 0x0b]`.
45 pub unknown3: Option<&'a [u8; 16]>,
46}
47
48impl<'a> FbxFooter<'a> {
49 /// Returns the first unknown field or default.
50 #[inline]
51 #[must_use]
52 pub(crate) fn unknown1(&self) -> &'a [u8; 16] {
53 /// Default value.
54 const DEFAULT: [u8; 16] = [
55 0xf0, 0xb1, 0xa2, 0x03, 0xd4, 0xc5, 0xd6, 0x67, 0xb8, 0x79, 0xfa, 0x8b, 0x1c, 0xfd,
56 0x2e, 0x7f,
57 ];
58 self.unknown1.unwrap_or(&DEFAULT)
59 }
60
61 /// Returns the second unknown field or default.
62 #[inline]
63 #[must_use]
64 pub(crate) fn unknown2(&self) -> [u8; 4] {
65 /// Default value.
66 const DEFAULT: [u8; 4] = [0; 4];
67 self.unknown2.unwrap_or(DEFAULT)
68 }
69
70 /// Returns the third unknown field or default.
71 #[inline]
72 #[must_use]
73 pub(crate) fn unknown3(&self) -> &'a [u8; 16] {
74 /// Default value.
75 const DEFAULT: [u8; 16] = [
76 0xf8, 0x5a, 0x8c, 0x6a, 0xde, 0xf5, 0xd9, 0x7e, 0xec, 0xe9, 0x0c, 0xe3, 0x75, 0x8f,
77 0x29, 0x0b,
78 ];
79 self.unknown3.unwrap_or(&DEFAULT)
80 }
81}