Skip to main content

animsmith_core/
lib.rs

1//! Engine-agnostic animation linting primitives for Rust pipelines.
2//!
3//! This crate is the embedding boundary for animsmith. It owns the core
4//! data model ([`Document`], [`Skeleton`], [`Clip`], [`Track`]), rig-role
5//! resolution ([`detect_profile`], [`ResolvedRoles::from_names`]),
6//! typed configuration ([`Config`]), measurement generation
7//! ([`measure::measure_document`]), measurement diffs
8//! ([`diff::diff_measurements`]), structured findings ([`Finding`]), and
9//! check execution ([`CheckCtx`], [`all_checks`], [`run_checks`]).
10//! The [`animsmith-gltf`] and [`animsmith-fbx`] loader crates translate file
11//! formats into this model; their docs.rs pages continue the library path for
12//! format-specific loading and, for glTF, writing.
13//!
14//! The [embedding guide] explains crate selection and integration
15//! boundaries. The [pipeline scenario guide] shows where an embedded gate
16//! fits in marketplace intake, mocap cleanup, outsourced acceptance, and CI.
17//! A [runnable example] exercises the complete library flow.
18//!
19//! [embedding guide]: https://github.com/mmannerm/animsmith/blob/main/docs/embedding.md
20//! [pipeline scenario guide]: https://github.com/mmannerm/animsmith/blob/main/docs/pipeline-scenarios.md
21//! [runnable example]: https://github.com/mmannerm/animsmith/blob/main/crates/animsmith/examples/embed.rs
22//! [`animsmith-gltf`]: https://docs.rs/animsmith-gltf
23//! [`animsmith-fbx`]: https://docs.rs/animsmith-fbx
24//!
25//! # Quick start
26//!
27//! After a format crate has loaded a [`Document`], resolve rig roles, build
28//! a [`Config`] from the host pipeline's contract, and share one
29//! [`MetricGrids`] between measurements, checks, and optional report
30//! generation:
31//!
32//! ```
33//! use animsmith_core::{Config, CheckCtx, Document, MetricGrids, all_checks, run_checks};
34//! use animsmith_core::measure::measure_document;
35//! use animsmith_core::ResolvedRoles;
36//!
37//! let doc = Document::default();
38//! let roles = ResolvedRoles::default();
39//! let config = Config::default();
40//! let grids = MetricGrids::new(&doc);
41//!
42//! let measurements = measure_document(&grids, &roles, &config);
43//! let ctx = CheckCtx::new(&grids, &roles, &config);
44//! let findings = run_checks(&ctx, &all_checks());
45//!
46//! assert!(measurements.is_empty());
47//! assert!(findings.is_empty());
48//! ```
49//!
50//! [`CheckCtx::new`] consumes already-resolved roles; it does not interpret
51//! [`Config::rig`] automatically. Frontends may use [`detect_profile`],
52//! [`profile::resolve_named`], or [`ResolvedRoles::from_names`], then apply
53//! their own override policy before constructing the context. Checks whose
54//! required roles remain unresolved emit diagnostic skip notes rather than
55//! false failures.
56//!
57//! # API status
58//!
59//! The Rust API is pre-1.0 and may still change before the first stable
60//! release. The intended extension points are the data model,
61//! configuration types, measurement and diff APIs, rig-profile APIs, the
62//! [`Check`] trait for custom checks, and the check catalog functions
63//! re-exported from this crate root. Built-in check ids, CLI exit-code
64//! semantics, and the CLI's versioned JSON envelope/schema id are treated
65//! as the most stable automation contracts. The core [`Finding`] and
66//! [`measure::ClipMeasurements`] serde shapes feed that envelope, but the
67//! envelope version itself lives in the CLI crate. The scene-asset
68//! structs in [`model`] and the pipeline-mechanical helpers in
69//! [`transform`] are public so the loader, writer, and CLI crates can
70//! share the same model, but they are less settled than the
71//! measurement/check embedding flow while the crate is pre-1.0. Metric
72//! formulas and individual Rust symbols are still subject to pre-1.0
73//! refinement.
74//!
75//! Public APIs that return [`Result`] document their `# Errors` cases.
76//! Index-based accessors and transform helpers that rely on
77//! loader-established invariants document their `# Panics` contracts.
78//! Loader-valid documents from the format crates should flow through
79//! checking, sampling, and measurement without panicking on untrusted
80//! input.
81
82#![warn(missing_docs)]
83
84pub mod check;
85mod checks;
86pub mod config;
87pub mod diff;
88pub mod finding;
89#[cfg(feature = "fixtures")]
90pub mod fixtures;
91pub mod measure;
92pub mod metrics;
93pub mod model;
94pub mod profile;
95pub mod sample;
96pub mod transform;
97
98pub use check::{Check, CheckCtx, all_checks, mechanical_checks, run_checks};
99pub use config::{ClipExpectations, Config, GaitGroup, Pinned, SeveritySetting};
100pub use finding::{Finding, Severity, Value};
101/// Re-export of the exact `glam` version used by animsmith's public math
102/// types, so embedders can construct [`Transform`] values without a
103/// cross-version type mismatch.
104pub use glam;
105pub use metrics::MetricGrids;
106pub use model::{
107    Bone, BoneId, Clip, Document, Interpolation, Property, Skeleton, SourceInfo, Track,
108    TrackValues, Transform,
109};
110pub use profile::{ResolvedRoles, RigProfile, Role, builtin_profiles, detect_profile};
111pub use sample::{PoseGrid, TrackSample, default_frame_count, sample_clip, sample_track};