1pub mod entry;
2pub mod structs;
3pub mod vpk;
4
5use thiserror::Error;
6
7pub use crate::vpk::VPK;
8
9use std::path::Path;
10use std::str::Utf8Error;
11
12#[derive(Debug, Error)]
13#[non_exhaustive]
14pub enum Error {
15 #[error("Error while trying to read data: {0}")]
16 ReadError(#[from] std::io::Error),
17 #[error("Error while trying to read data: {0}")]
18 BinReadError(#[from] binrw::Error),
19 #[error("Invalid signature, provided file is not a VPK file")]
20 InvalidSignature,
21 #[error("Unsupported VPK version({0}), only version 2 and low")]
22 UnsupportedVersion(u32),
23 #[error("Mismatched size for hashes section")]
24 HashSizeMismatch,
25 #[error("Malformed index encountered while parsing")]
26 MalformedIndex,
27 #[error("Invalid utf8 string found while parsing")]
28 Utf(#[from] Utf8Error),
29 #[error("Filename not available")]
30 FilenameNotAvailable,
31 #[error("Filename not representable as str")]
32 FilenameNotRepresentableAsStr,
33}
34
35#[doc(alias = "read")]
37pub fn from_path(path: impl AsRef<Path>) -> Result<VPK, Error> {
38 VPK::read(path)
39}