fakejpeg/
lib.rs

1// SPDX-FileCopyrightText: 2025 Alun Jones
2// SPDX-FileCopyrightText: 2025 Gergely Nagy
3// SPDX-FileContributor: Gergely Nagy
4//
5// SPDX-License-Identifier: MIT
6
7#![warn(missing_docs)]
8
9//! **"Fake" jpeg generator library for Rust**
10//!
11//! This library began as a port of Alun Jones' [`fakejpeg`] Python library to
12//! Rust, using `winnow` for parsing, and with a focus on performance. Much like
13//! the original library, the generated images aren't exactly correct, but
14//! they're - usually - good enough that browsers, and a lot of image viewers
15//! display them nevertheless.
16//!
17//! The main components of the library are [`Template`] and [`ImageGenerator`]:
18//! these can be used to parse JPEG images into a template, and to generate
19//! randomized fakes from said template, as many as you wish.
20//!
21//! While a [`Template`] is expensive to build, an [`ImageGenerator`] isn't: it
22//! borrows the template for generation purposes. As such, it is recommended to
23//! keep a [`Template`] around as long as possible - you're free to create and
24//! drop [`ImageGenerator`]s as needed, they're not much more than a thin
25//! wrapper around the template.
26//!
27//! [`fakejpeg`]: https://github.com/gw1urf/fakejpeg
28
29/// A collection of all the possible error types the library can return.
30pub mod error;
31mod image_generator;
32mod masked_rng;
33mod parser;
34mod template;
35
36pub use image_generator::{
37    ImageGenerator,
38    config::{Config, Options},
39};
40pub use template::Template;
41
42#[cfg(feature = "serde")]
43pub use template::pickle::Pickle;