Struct self_encryption::SelfEncryptor [] [src]

pub struct SelfEncryptor<'a, E: StorageError, S: 'a + Storage<E>> {
    // 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.

Methods

impl<'a, E: StorageError, S: Storage<E>> SelfEncryptor<'a, E, S>
[src]

fn new(storage: &'a mut S, data_map: DataMap) -> Result<SelfEncryptor<'a, E, S>, SelfEncryptionError<E>>

This is the only constructor for an encryptor object. Each SelfEncryptor is used for a single file. The parameters are a Storage object and a DataMap. For a file which has not previously been self-encrypted, use DataMap::None.

fn write(&mut self, data: &[u8], position: u64) -> Result<()SelfEncryptionError<E>>

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) -> Result<Vec<u8>, SelfEncryptionError<E>>

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

fn close(self) -> Result<DataMapSelfEncryptionError<E>>

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

fn truncate(&mut self, new_size: u64) -> Result<()SelfEncryptionError<E>>

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

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<'a, E: StorageError, S: Storage<E>> Debug for SelfEncryptor<'a, E, S>
[src]

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

Formats the value using the given formatter.