Struct self_encryption::SequentialEncryptor [−][src]
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.
Implementations
impl<S> Encryptor<S> where
S: Storage + 'static + Send + Sync,
[src]
S: Storage + 'static + Send + Sync,
pub async fn new(
storage: S,
data_map: Option<DataMap>
) -> Result<Encryptor<S>, SelfEncryptionError>
[src]
storage: S,
data_map: Option<DataMap>
) -> Result<Encryptor<S>, SelfEncryptionError>
Creates an Encryptor
, using an existing DataMap
if data_map
is not None
.
pub async fn write(&self, data: &[u8]) -> Result<(), SelfEncryptionError>
[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 async fn close(self) -> Result<(DataMap, S), SelfEncryptionError>
[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 async fn len(&self) -> usize
[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 async fn is_empty(&self) -> bool
[src]
Returns true if len() == 0
.
Auto Trait Implementations
impl<S> !RefUnwindSafe for Encryptor<S>
impl<S> Send for Encryptor<S>
impl<S> Sync for Encryptor<S>
impl<S> Unpin for Encryptor<S>
impl<S> !UnwindSafe for Encryptor<S>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,