Struct self_encryption::SequentialEncryptor
[−]
[src]
pub struct SequentialEncryptor<S> { /* 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<S> Encryptor<S> where
S: Storage + 'static,
[src]
S: Storage + 'static,
fn new(
storage: S,
data_map: Option<DataMap>
) -> Box<Future<Item = Encryptor<S>, Error = SelfEncryptionError<S::Error>>>
[src]
storage: S,
data_map: Option<DataMap>
) -> Box<Future<Item = Encryptor<S>, Error = SelfEncryptionError<S::Error>>>
Creates an Encryptor
, using an existing DataMap
if data_map
is not None
.
fn write(
&self,
data: &[u8]
) -> Box<Future<Item = (), Error = SelfEncryptionError<S::Error>>>
[src]
&self,
data: &[u8]
) -> Box<Future<Item = (), Error = SelfEncryptionError<S::Error>>>
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()
.
fn close(
self
) -> Box<Future<Item = (DataMap, S), Error = SelfEncryptionError<S::Error>>>
[src]
self
) -> Box<Future<Item = (DataMap, S), Error = SelfEncryptionError<S::Error>>>
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.
fn len(&self) -> u64
[src]
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.
fn is_empty(&self) -> bool
[src]
Returns true if len() == 0
.