[][src]Struct matrix_sdk_crypto::AttachmentEncryptor

pub struct AttachmentEncryptor<'a, R: Read + 'a> { /* fields omitted */ }

A wrapper that transparently encrypts anything that implements Read.

Implementations

impl<'a, R: Read + 'a> AttachmentEncryptor<'a, R>[src]

pub fn new(reader: &'a mut R) -> Self[src]

Wrap the given reader encrypting all the data we read from it.

After all the reads are done, and all the data is encrypted that we wish to encrypt a call to finish() is necessary to get the decryption key for the data.

Arguments

  • reader - The Reader that should be wrapped and enrypted.

Panics

Panics if we can't generate enough random data to create a fresh encryption key.

Examples

let data = "Hello world".to_owned();
let mut cursor = Cursor::new(data.clone());

let mut encryptor = AttachmentEncryptor::new(&mut cursor);

let mut encrypted = Vec::new();
encryptor.read_to_end(&mut encrypted).unwrap();
let key = encryptor.finish();

pub fn finish(self) -> EncryptionInfo[src]

Consume the encryptor and get the encryption key.

Trait Implementations

impl<'a, R: Debug + Read + 'a> Debug for AttachmentEncryptor<'a, R>[src]

impl<'a, R: Read + 'a> Read for AttachmentEncryptor<'a, R>[src]

Auto Trait Implementations

impl<'a, R> RefUnwindSafe for AttachmentEncryptor<'a, R> where
    R: RefUnwindSafe
[src]

impl<'a, R> Send for AttachmentEncryptor<'a, R> where
    R: Send
[src]

impl<'a, R> Sync for AttachmentEncryptor<'a, R> where
    R: Sync
[src]

impl<'a, R> Unpin for AttachmentEncryptor<'a, R>[src]

impl<'a, R> !UnwindSafe for AttachmentEncryptor<'a, R>[src]

Blanket Implementations

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

impl<T> AsyncTraitDeps for T where
    T: Send + Sync + Debug
[src]

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

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

impl<T> Conv for T

impl<T> Conv for T

impl<T> FmtForward for T

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

impl<T> Instrument for T[src]

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

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<R> ReadBytesExt for R where
    R: Read + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> TryConv for T

impl<T> TryConv for T

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<V, T> VZip<V> for T where
    V: MultiLane<T>,