Crate sqlarfs

Source
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.
ArchiveOptions
Options for archiving files in the filesystem to an Archive.
Connection
A connection to a SQLite database.
ExtractOptions
Options for extracting files in an Archive into the filesystem.
File
A file in a SQLite archive.
FileMode
A Unix file mode.
FileReader
A readable stream of the data in a File.
ListEntries
An iterator over the files in an archive.
ListEntry
An entry when iterating over a list of files.
ListOptions
Options for sorting and filtering a list of files.
SqliteErrorCode
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.
FileMetadata
The metadata of a file in a SQLite archive.
FileType
The type of a file, either a regular file, a directory, or a symbolic link.
TransactionBehavior
The behavior of a SQLite transaction.

Type Aliases§

Result
The result type for sqlarfs.