Struct self_encryption::SequentialEncryptor [] [src]

pub struct SequentialEncryptor<'a, E: StorageError, S: 'a + Storage<E>> { /* fields omitted */ }

An encryptor which only permits sequential writes, i.e. there is no ability to specify an offset in the write() call; all data is appended sequentially.

The resulting chunks and DataMap are identical to those which would have been produced by a SelfEncryptor.

This encryptor differs from SelfEncryptor in that completed chunks will be stored during write() calls as opposed to buffering all data until the close() call. This should give more realistic feedback about the progress of fully self-encrypting larger data.

A further difference is that since the entire data is not held in an internal buffer, this encryptor doesn't need to limit the input data size, i.e. MAX_FILE_SIZE does not apply to this encryptor. (Note that as of writing, there is no way to decrypt data which exceeds this size, since the only decryptor available is SelfEncryptor, and this does limit the data size to MAX_FILE_SIZE.)

Due to the reduced complexity, a side effect is that this encryptor outperforms SelfEncryptor, particularly for small data (below MIN_CHUNK_SIZE * 3 bytes) where no chunks are generated.

Methods

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

Creates an Encryptor, using an existing DataMap if data_map is not None.

Buffers some or all of data and stores any completed chunks (i.e. those which cannot be modified by subsequent write() calls). The internal buffers can only be flushed by calling close().

This finalises the encryptor - it should not be used again after this call. Internal buffers are flushed, resulting in up to four chunks being stored.

Number of bytes of data written, including those handled by previous encryptors.

E.g. if this encryptor was constructed with a DataMap whose len() yields 100, and it then handles a write() of 100 bytes, len() will return 200.

Returns true if len() == 0.