minecraft_assets/api/
mod.rs

1//! An API for programmatically accessing Minecraft resources and associated
2//! metadata.
3//!
4//! ## Resource Locations
5//!
6//! Every resource is associated with a unique [`ResourceLocation`], which is a
7//! combination of a [`ResourceKind`] and a *namespaced identifier*.
8//!
9//! ## Providers
10//!
11//! Resources can be enumerated and loaded using the [`ResourceProvider`] trait.
12//! This crate provides the [`FileSystemResourceProvider`] as a convenient
13//! implementation of this trait.
14//!
15//! ## Asset Pack
16//!
17//! Resources can be ergonomically loaded through the [`AssetPack`] API.
18
19use std::io;
20
21mod asset_pack;
22mod provider;
23mod resolve;
24mod resource;
25
26pub use asset_pack::AssetPack;
27pub use provider::{
28    EnumerateResources, FileSystemResourceProvider, LoadResource, ResourceProvider,
29};
30pub use resolve::ModelResolver;
31pub use resource::{
32    ModelIdentifier, ResourceCategory, ResourceKind, ResourceLocation, ResourcePath,
33    MINECRAFT_NAMESPACE,
34};
35
36/// Error types that can be returned from API methods.
37#[derive(Debug, thiserror::Error)]
38#[allow(missing_docs)]
39pub enum Error {
40    #[error(transparent)]
41    IoError(#[from] io::Error),
42
43    #[error(transparent)]
44    ParseError(#[from] serde_json::Error),
45}
46
47/// Result alias for convenience.
48pub type Result<T, E = Error> = std::result::Result<T, E>;