Expand description
A file archive format and virtual filesystem backed by a SQLite database.
This library is a Rust implementation of the sqlar format for SQLite archive files.
use std::io::prelude::*;
use sqlarfs::Connection;
fn main() -> sqlarfs::Result<()> {
let mut conn = Connection::open_in_memory()?;
let expected = "hello world";
let actual = conn.exec(|archive| {
let mut dir = archive.open("path/to")?;
dir.create_dir_all()?;
let mut file = archive.open("path/to/file")?;
file.create_file()?;
file.write_str(expected)?;
let mut actual = String::new();
let mut reader = file.reader()?;
reader.read_to_string(&mut actual)?;
sqlarfs::Result::Ok(actual)
})?;
assert_eq!(actual, expected);
Ok(())
}
To open a SQLite archive, create a new Connection
. From there, you can call
Connection::exec
to execute a closure within a transaction. This closure will be passed an
Archive
, which is the main type for reading and writing to the archive.
Structs§
- Archive
- A SQLite archive.
- Archive
Options - Options for archiving files in the filesystem to an
Archive
. - Connection
- A connection to a SQLite database.
- Extract
Options - Options for extracting files in an
Archive
into the filesystem. - File
- A file in a SQLite archive.
- File
Mode - A Unix file mode.
- File
Reader - A readable stream of the data in a
File
. - List
Entries - An iterator over the files in an archive.
- List
Entry - An entry when iterating over a list of files.
- List
Options - Options for sorting and filtering a list of files.
- Sqlite
Error Code - An opaque type representing a SQLite error code.
- Transaction
- An open transaction on an
Archive
.
Enums§
- Compression
- The compression method to use when writing to a
File
. - Error
- The error type for sqlarfs.
- File
Metadata - The metadata of a file in a SQLite archive.
- File
Type - The type of a file, either a regular file, a directory, or a symbolic link.
- Transaction
Behavior - The behavior of a SQLite transaction.
Type Aliases§
- Result
- The result type for sqlarfs.