lib.rs 988 B

1234567891011121314151617181920212223
  1. //! Offline conversion of the user's game data into host formats.
  2. //!
  3. //! Everything here runs on the user's machine, reads the user's files and
  4. //! writes into the user's cache. Nothing produced here is ever committed:
  5. //! derived data is still game data (docs/asset-policy.md).
  6. //!
  7. //! The unit of work is a [`Converter`]: bytes in, bytes out, deterministic.
  8. //! Results are stored in a content-addressed [`Cache`] keyed by converter
  9. //! id, converter version and input bytes, so re-running the pipeline after
  10. //! a game update or a converter fix only redoes what changed.
  11. mod cache;
  12. pub use cache::{Cache, CacheKey};
  13. /// A deterministic transformation of one input into one output.
  14. pub trait Converter: Send + Sync {
  15. /// Stable identifier, e.g. `"texture.detile"`. Part of the cache key.
  16. fn id(&self) -> &'static str;
  17. /// Bump whenever the output for a given input changes.
  18. fn version(&self) -> u32;
  19. fn convert(&self, input: &[u8]) -> anyhow::Result<Vec<u8>>;
  20. }