Crate zbox [−] [src]
Zbox is a zero-details, privacy-focused embeddable file system.
It keeps files securely, privately and reliably on underlying storages. By encapsulating files and directories into an encrypted repository, it provides a virtual file system and exclusive access to authorised application.
The most core parts of this module are Repo
and File
, which provides
most file system operations and file I/O.
Repo
provides similar file system manipulation methods tostd::fs
File
provides similar file I/O methods tostd::fs::File
init_env
initialises the environment and should be called before
any other methods provied by Zbox.
After repository is opened by RepoOpener
, all of the other functions
provided by Zbox will be thread-safe.
Examples
Create and open a Repo
using OS file system as storage.
use zbox::{init_env, RepoOpener}; // initialise zbox environment, called first init_env(); // create and open a repository let mut repo = RepoOpener::new() .create(true) .open("file://./my_repo", "your password") .unwrap();
File
content IO using Read
and Write
traits.
use std::io::prelude::*; use zbox::OpenOptions; // create and open a file for writing let mut file = OpenOptions::new() .create(true) .open(&mut repo, "/my_file.txt") .unwrap(); // use std::io::Write trait to write data into it file.write_all(b"Hello, world!").unwrap(); // finish writting to make a permanent version of content file.finish().unwrap(); // read file content using std::io::Read trait let mut content = String::new(); file.read_to_string(&mut content).unwrap(); assert_eq!(content, "Hello, world!");
Directory navigation can use Path
and PathBuf
. The path separator
should always be "/".
use std::path::Path; let path = Path::new("/foo/bar"); repo.create_dir_all(&path).unwrap(); assert!(repo.is_dir(path.parent().unwrap()));
Structs
DirEntry |
Entries returned by the |
Eid |
Unique entity ID. |
File |
A reference to an open file in the repository. |
Metadata |
Metadata information about a file or a directory. |
OpenOptions |
Options and flags which can be used to configure how a file is opened. |
Repo |
An encrypted repository contains the whole file system. |
RepoInfo |
Information about a repository. |
RepoOpener |
A builder used to create a repository |
Version |
A representation of a permanent file content. |
VersionReader |
A reader for a specific vesion of file content. |
Enums
Cipher |
Crypto cipher primitivies. |
Error | |
FileType |
A structure representing a type of file with accessors for each file type. |
MemLimit |
Password hash memory limit. |
OpsLimit |
Password hash operation limit. |
Functions
init_env |
Initialise Zbox environment. |
Type Definitions
Result |
A specialized |