[][src]Struct self_encryption::SequentialEncryptor

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]

pub fn new(
    storage: S,
    data_map: Option<DataMap>
) -> Box<dyn Future<Item = Encryptor<S>, Error = SelfEncryptionError<S::Error>>>
[src]

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

pub fn write(
    &self,
    data: &[u8]
) -> Box<dyn Future<Item = (), Error = SelfEncryptionError<S::Error>>>
[src]

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().

pub fn close(
    self
) -> Box<dyn Future<Item = (DataMap, S), Error = SelfEncryptionError<S::Error>>>
[src]

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.

pub 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.

pub fn is_empty(&self) -> bool[src]

Returns true if len() == 0.

Auto Trait Implementations

impl<S> !Send for Encryptor<S>

impl<S> !Sync for Encryptor<S>

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]