Skip to main content

Decryptor

Struct Decryptor 

Source
pub struct Decryptor<'a, 'ctx> { /* private fields */ }
Expand description

Builder over a decryption operation. Mirrors Encryptor for symmetry.

Returns a DecryptResult that exposes both the plaintext bytes and the rich metadata surface (recipient / symenc / file info / protection info / format) by delegating to the underlying verify-op result.

For the simple “just give me the plaintext” case, prefer decrypt — it’s a thinner wrapper over rnp_decrypt and avoids the verify-op overhead.

build consumes the ciphertext twice (see below), so Decryptor only accepts byte slices. To decrypt from a one-shot stream (a reader that cannot be rewound), use decrypt_from_input instead.

let result = Decryptor::new(&ctx, &ciphertext).build().unwrap();
let _plaintext = result.plaintext();
let _recipients = result.recipient_count().unwrap();

Implementations§

Source§

impl<'a, 'ctx> Decryptor<'a, 'ctx>

Source

pub fn new(ctx: &'ctx Context, ciphertext: &'a [u8]) -> Self

Source

pub fn build(self) -> Result<DecryptResult<'ctx>>

Execute the decryption, returning the plaintext and rich metadata.

This runs the decryption pipeline twice: once via rnp_decrypt to extract the plaintext bytes, and once via rnp_op_verify_* to collect recipient/symenc/file-info metadata. The double pass is necessary because the verify-op surface doesn’t expose its output bytes after execute (the output is destroyed with the op).

Auto Trait Implementations§

§

impl<'a, 'ctx> !RefUnwindSafe for Decryptor<'a, 'ctx>

§

impl<'a, 'ctx> !Send for Decryptor<'a, 'ctx>

§

impl<'a, 'ctx> !Sync for Decryptor<'a, 'ctx>

§

impl<'a, 'ctx> !UnwindSafe for Decryptor<'a, 'ctx>

§

impl<'a, 'ctx> Freeze for Decryptor<'a, 'ctx>

§

impl<'a, 'ctx> Unpin for Decryptor<'a, 'ctx>

§

impl<'a, 'ctx> UnsafeUnpin for Decryptor<'a, 'ctx>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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.