docs.rs failed to build ucvt-0.1.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
ucvt
Universal Converter — image and structured-text format conversion for Rust and C.
Features
| Domain | Formats |
|---|---|
| Image | PNG, JPEG, GIF, BMP, ICO, TIFF, WebP |
| Text | JSON, TOML, YAML, XML / XAML |
Every conversion is available in four call shapes:
| Function | Description |
|---|---|
b2b |
bytes → bytes |
b2f |
bytes → file (format inferred from extension) |
f2b |
file → bytes |
f2f |
file → file |
d2d |
directory / glob / %d pattern → directory |
Batch operations (d2d) run in parallel via rayon.
The crate also exposes a C ABI (cdylib) so the same conversions can be called from C, C++, Python, C#, and any other language that supports the C calling convention.
Usage
[]
= "0.1.0"
Image conversion
use img;
use ImageFormat;
// file → file (formats inferred from extensions)
f2f?;
// bytes → bytes
let png_bytes = read?;
let jpeg_bytes = b2b?;
// batch: convert every file in a directory
d2d?;
// batch: glob pattern
d2d?;
// batch: ffmpeg-style sequential numbering
d2d?;
Structured-text conversion
use ;
// file → file
f2f?;
// bytes → bytes
let json = br#"{"name": "Alice", "age": 30}"#;
let toml_bytes = b2b?;
// batch
d2d?;
d2d?;
C ABI
The cdylib target exports extern "C" functions prefixed with i_ (image) and t_ (text):
// image
bool ;
bool ;
bool ;
void ;
// text
bool ;
bool ;
bool ;
bool ;
bool ;
void ;
Format codes
Image (i_* functions):
| Code | Format |
|---|---|
| 0 | PNG |
| 1 | JPEG |
| 2 | GIF |
| 3 | BMP |
| 4 | ICO |
| 5 | TIFF |
| 6 | WebP |
Text (t_* functions):
| Code | Format |
|---|---|
| 0 | JSON |
| 1 | TOML |
| 2 | YAML |
| 3 | XML / XAML |
License
MIT