1#![doc = include_str!("../README.md")]
2#![warn(missing_docs)]
3#![warn(clippy::missing_docs_in_private_items)]
4
5pub mod doc;
6pub mod parsed;
7pub mod raw;
8pub mod shared;
9
10#[doc(inline)]
11pub use parsed::Movie;
12
13#[doc(inline)]
14pub use raw::RawMovie;
15
16#[derive(Debug, thiserror::Error)]
18pub enum MovieError {
19 #[error("Failed to read movie data: {0}")]
21 BinRWError(#[from] binrw::Error),
22 #[error("Failed to read file: {0}")]
24 FileError(#[from] std::io::Error),
25 #[error("Failed to parse string: {0}")]
27 FixedStrError(#[from] EncodedFixedStrError),
28 #[error("Failed to parse movie: {0}")]
30 MovieParseError(#[from] MovieParseError),
31}
32
33#[derive(Debug, thiserror::Error)]
35pub enum EncodedFixedStrError {
36 #[error("Invalid UTF-8 string: {0}")]
38 Utf8Error(#[from] std::str::Utf8Error),
39 #[error("Invalid ASCII string: {0}")]
41 InvalidAscii(String),
42 #[error("Fixed string error: {0}")]
44 FixedStrError(String),
45}
46
47#[derive(Debug, thiserror::Error)]
49pub enum MovieParseError {
50 #[error("Invalid movie version: {0}")]
52 UnsupportedVersion(u32),
53 #[error("Invalid movie extended version: {0}")]
55 UnsupportedExtendedVersion(u8),
56}
57
58pub trait BinReadExt
60where
61 Self: Sized,
62{
63 type Error;
65 fn from_bytes(bytes: &[u8]) -> Result<Self, Self::Error>;
67 fn from_file<P: AsRef<std::path::Path>>(path: P) -> Result<Self, Self::Error>;
69}
70
71pub trait BinWriteExt {
73 type Error;
75 fn to_bytes(&self) -> Result<Vec<u8>, Self::Error>;
77 fn to_file<P: AsRef<std::path::Path>>(&self, path: P) -> Result<(), Self::Error>;
79}
80
81#[derive(Debug, Copy, Clone, Eq, PartialEq)]
83pub enum ControllerButton {
84 DPadRight,
86 DPadLeft,
88 DPadDown,
90 DPadUp,
92 Start,
94 Z,
96 B,
98 A,
100 CRight,
102 CLeft,
104 CDown,
106 CUp,
108 TriggerRight,
110 TriggerLeft,
112 Reserved01,
114 Reserved02,
116}