vrm-runtime 0.1.0

Renderer-agnostic VRM 1.0 loader, validator, animation system, and runtime
Documentation
use std::path::PathBuf;

/// Errors raised while loading and parsing a VRM 1.0 avatar.
#[derive(Debug, thiserror::Error)]
pub enum LoadError {
    /// Reading a file or an external buffer/image URI failed.
    #[error("failed to read `{path}`: {source}")]
    Io {
        /// Path that could not be read.
        path: PathBuf,
        /// Underlying file-system error.
        #[source]
        source: std::io::Error,
    },

    /// The glTF container or core document is malformed.
    #[error("glTF parse error: {0}")]
    Gltf(#[from] gltf::Error),

    /// A VRM extension payload could not be decoded as JSON.
    #[error("JSON deserialize error: {0}")]
    Json(#[from] serde_json::Error),

    /// The document declares the unsupported VRM 0.x format.
    #[error("VRM 0.x specification is not supported. Please use VRM 1.0 (VRMC_VRM) models.")]
    UnsupportedVrmVersion,

    /// The required top-level `VRMC_vrm` extension is absent.
    #[error("VRMC_VRM extension missing")]
    MissingVrmExtension,

    /// The document violates a VRM or supported glTF semantic requirement.
    #[error("invalid VRM document: {0}")]
    InvalidVrm(String),

    /// The document requires an extension that this crate cannot evaluate.
    #[error("required extension `{0}` is not supported")]
    UnsupportedRequiredExtension(String),

    /// A supported extension object is malformed at a known document location.
    #[error("invalid `{extension}` extension at {location}: {source}")]
    InvalidExtension {
        /// Extension identifier whose payload failed to decode.
        extension: &'static str,
        /// JSON-style path to the malformed extension object.
        location: String,
        /// Underlying JSON decoding error.
        #[source]
        source: serde_json::Error,
    },
}

/// Errors raised when a programmatically assembled asset is finalized.
#[derive(Debug, thiserror::Error)]
pub enum BuildError {
    /// The assembled object graph violates an asset invariant.
    #[error("invalid avatar asset: {0}")]
    InvalidAsset(String),
}