Skip to main content

StreamEncryptor

Struct StreamEncryptor 

Source
pub struct StreamEncryptor<C: ChunkGenerator> { /* private fields */ }

Implementations§

Source§

impl StreamEncryptor<RandomChunkGenerator>

Source

pub fn with_rand_chunks( file_name: &str, password: &str, chunking_threshold: u64, min_chunk_size: u64, max_chunk_size: u64, ) -> Result<Self, Error>

Source

pub fn with_rand_chunks_seed( file_name: &str, password: &str, chunking_threshold: u64, min_chunk_size: u64, max_chunk_size: u64, seed: u128, ) -> Result<Self, Error>

Source§

impl<C: ChunkGenerator> StreamEncryptor<C>

Source

pub fn process_data(&mut self, data: &[u8]) -> Vec<Chunk>

Processes given data.

This is the main processing loop to be called repetitively until end of stream.

Source

pub fn on_end_of_data(&mut self) -> Vec<Chunk>

Finalizes the encryption

Must be called when the stream is exhausted to get the last remaining chunks to encrypt.

Source

pub fn chunk_hash_algorithm(&self) -> ChecksumAlgorithm

Returns the identifier of the algorithm to use for computing chunk checksums

Source

pub fn encrypt_chunk(&self, chunk: &Chunk) -> Result<Blob, Error>

Returns the given chunk as encrypted data

Source

pub fn encrypt_chunks( &self, chunks: &Vec<Chunk>, ) -> Result<Vec<(u64, Blob)>, Error>

Returns the given chunks as encrypted data

@pre c.is_ready() for all c in chunks

Source

pub fn parallel_encrypt_chunks( &mut self, max_threads: u32, chunks: &Vec<Chunk>, ) -> Result<Vec<(u64, Blob)>, Error>

Source

pub fn register_encrypted_chunk( &self, chunk_index: u64, id: &str, ) -> Result<(), Error>

Associates a string id to an encrypted chunk identified by its index

Source

pub fn finalize(&mut self) -> Result<Blob, Error>

Finalizes the encryption and returns the encrypted manifest @pre on_end_of_data has been called and all chunks have been encrypted and registered

Source

pub fn get_registered_chunk_id(&self, chunk_index: u64) -> Result<String, Error>

Gets the id assigned to chunk at index chunk_index @pre chunk of index chunk_index as been registered by calling register_encrypted_chunk

Source

pub fn get_chunks_count(&self) -> u64

Returns the total number of chunks so far Increases as we keep piling chunks but may decrease e.g. on finalize if merging last chunks

Source

pub fn get_registered_chunks_count(&self) -> u64

Returns the number of registered encrypted chunks i.e. the number of chunks on which register_encrypted_chunk has been called.

Source

pub fn get_chunk_ids(&self) -> Vec<String>

Returns the chunk ids @pre All chunks have been registered and finalize() has been called

Auto Trait Implementations§

§

impl<C> Freeze for StreamEncryptor<C>
where C: Freeze,

§

impl<C> !RefUnwindSafe for StreamEncryptor<C>

§

impl<C> Send for StreamEncryptor<C>

§

impl<C> Sync for StreamEncryptor<C>

§

impl<C> Unpin for StreamEncryptor<C>
where C: Unpin,

§

impl<C> UnsafeUnpin for StreamEncryptor<C>
where C: UnsafeUnpin,

§

impl<C> !UnwindSafe for StreamEncryptor<C>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V