Struct self_encryption::SelfEncryptor [] [src]

pub struct SelfEncryptor<S: Storage> {
    // some fields omitted
}

This is the encryption object and all file handling should be done using this object as the low level mechanism to read and write content. This library has no knowledge of file metadata. This is a library to ensure content is secured.

Methods

impl<S: Storage + Send + Sync + 'static> SelfEncryptor<S>
[src]

fn new(storage: Arc<S>, datamap: DataMap) -> SelfEncryptor<S>

This is the only constructor for an encryptor object. Each SelfEncryptor is used for a single file. The parameters are a DataMap and Storage. If new file, use DataMap::None as first parameter. The get and put of Storage need to be implemented to allow the SelfEncryptor to store encrypted chunks and retrieve them when necessary.

fn get_storage(&self) -> Arc<S>

This is an implementation of the get_storage function from example.

fn write(&mut self, data: &[u8], position: u64)

Write method mirrors a posix type write mechanism. It loosely mimics a filesystem interface for easy connection to FUSE like programs as well as fine grained access to system level libraries for developers. The input data will be written from the specified position (starts from 0).

fn read(&mut self, position: u64, length: u64) -> Vec<u8>

The returned content is read from the specified position with specified length. Trying to read beyond the file size will cause the self_encryptor to return content filled with 0u8 in the gap (file size isn't affected). Any other unwritten gaps will also be filled with '0u8's.

fn close(self) -> DataMap

This function returns a DataMap, which is the info required to recover encrypted content from data storage location. Content temporarily held in self_encryptor will only get flushed into storage when this function gets called.

fn truncate(&mut self, new_size: u64) -> bool

Truncate the self_encryptor to the specified size (if extended, filled with 0u8).

fn len(&self) -> u64

Current file size as is known by encryptor.

fn is_empty(&self) -> bool

Returns true if file size as is known by encryptor == 0.

Trait Implementations

impl<S: Storage + Send + Sync + 'static> Debug for SelfEncryptor<S>
[src]

fn fmt(&self, formatter: &mut Formatter) -> Result

Formats the value using the given formatter.