1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (c) 2025-present, fjall-rs
// This source code is licensed under both the Apache 2.0 and MIT License
// (found in the LICENSE-* files in the repository)
//! *SFA* (**s**imple **f**ile-**b**ased **a**rchive) is a minimal, flat file archive encoding/decoding library for Rust.
//!
//! The file can be segmented into multiple sections (similar to a zip file), and individual sections accessed as a [`std::io::Read`].
//!
//! ```
//! use sfa::{Writer, Reader};
//! use std::{
//! fs::File,
//! io::{BufWriter, Read, Write}
//! };
//! # let dir = tempfile::tempdir()?;
//! # let path = dir.path().join("hello.sfa");
//!
//! let file = File::create(&path)?;
//! let mut file = BufWriter::new(file);
//! let mut writer = Writer::from_writer(&mut file);
//!
//! writer.start("Section 1")?;
//! writer.write_all(b"Hello world!\n")?;
//!
//! writer.finish()?;
//! file.get_mut().sync_all()?;
//! drop(file);
//! // If on Unix, you probably want to fsync the directory here
//!
//! let reader = Reader::new(&path)?;
//! let toc = reader.toc();
//! assert_eq!(toc.len(), 1);
//! assert_eq!(toc[0].name(), b"Section 1");
//! assert_eq!(toc[0].len(), 13);
//!
//! let reader = toc[0].buf_reader(&path).unwrap();
//! assert_eq!(b"Hello world!\n", &*reader.bytes().collect::<Result<Vec<_>, _>>()?);
//! #
//! # Ok::<(), sfa::Error>(())
//! ```
// #![doc(html_logo_url = "https://raw.githubusercontent.com/fjall-rs/sfa/main/logo.png")]
// #![doc(html_favicon_url = "https://raw.githubusercontent.com/fjall-rs/sfa/main/logo.png")]
pub type Result<T> = Result;
pub use Checksum;
pub use Error;
pub use Reader;
pub use ;
pub use Writer;