| Crates.io | sf3 |
| lib.rs | sf3 |
| version | 0.1.1 |
| created_at | 2025-07-01 21:23:15.541882+00 |
| updated_at | 2025-07-01 21:23:15.541882+00 |
| description | An implementation of the Simple File Format Family in Rust. |
| homepage | |
| repository | https://git.average.name/AverageHelper/sf3-rust |
| max_upload_size | |
| id | 1734000 |
| size | 118,485 |
An implementation of SF3 (Simple File Format Family) in Rust. See the spec at https://shirakumo.org/docs/sf3
[!WARNING] This crate is experimental, and a work-in-progress. Expect major breaking changes until v1.0.
Feedback is appreciated, either via an issue or contacting me directly!
This crate is a work-in-progress. The following functions have been implemented and tested:
std::io::Read readerno_std supportThe following formats have yet to be implemented:
See the examples directory. Run an example using cargo run --example <example>
chrono for parsing timestamp values (see the Archive file type)const-str and const_panic for constructing sized strings from string literalscrc32fast for computing CRC32 checksumshalf for handling 16-bit floats until f16 stabilizes (see the Audio file type)mediatype for parsing and serving MIME typestimeout-readwrite for ensuring File I/O doesn't hang when it should time outParse from memory:
use sf3::file::Sf3File;
use sf3::Archive;
let archive_bytes: &[u8] = /* ... */;
let archive = Archive::parse_bytes(archive_bytes).unwrap();
assert_eq!(archive.payload.len(), 2);
Parse from file:
use sf3::file::Sf3File;
use sf3::Archive;
let file = std::fs::File::open("/path/to/example.ar.sf3")?;
let archive = Archive::parse_file(file).unwrap();
assert_eq!(archive.payload.len(), 2);
Parse from Reader or custom buffer:
use sf3::file::Sf3File;
use sf3::Archive;
let stream: impl std::io::Read = /* ... */;
let buf = std::io::BufReader::new(stream);
let archive = Archive::parse_io(Box::new(buf)).unwrap();
assert_eq!(archive.payload.len(), 2);
MIME type (const compatible):
use mediatype::MediaType;
// mime-types for specific formats
let archive_type: MediaType = sf3::Archive::MIME;
let audio_type: MediaType = sf3::Archive::MIME;
// mime-type for a general SF3 file (may change in future with IANA registration)
let sf3_type: MediaType = sf3::file::MIME;
stdThis feature is enabled by default, and enables support for parsing files from Read types, and certain features in chrono, const-str, crc32fast, and half which require Rust's std crate. All functions work well enough without std, including parsing from byte slices and generating new byte representations of SF3 files, so if you're writing a no_std crate or targeting an environment where std isn't available but alloc and core are, then you may disable this feature without much consequence.
serdeDisabled by default. Enables serde support for chrono, half, and mediatype types.
Run code-coverage tests using the test.sh script.
Regular unit tests can be run using cargo test. Use the --no-default-features flag to test no_std support.
The tests/ directory contains sample files to test against. These are copied directly from the Shirakumo/sf3 repository, and may be out of date.
Suggestions and code contributions are welcome! The codebase lives primarily at git.average.name, where you may file issues or pull requests using a fresh account there or an existing account with Codeberg or the like.
A read-only code mirror of this project also exists at Codeberg.
The SF3 spec was written by Yukari Hafner at Shirakumo, under the zlib License.