Skip to content

Commit 8bb7ef1

Browse files
committed
docs(stack-encrypt): the source modes are uninhabited and hold no plaintext
Review of #1068 asked whether Borrowed and Owned should derive OpaqueDebug because they stand for a plaintext. They are uninhabited marker enums: no value of either type exists, so their Debug impl can print nothing. The doc now says so, and names where the plaintext actually lives (the description's closure, which has no Debug, and the Pending output).
1 parent cec43b5 commit 8bb7ef1

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎packages/stack-encrypt/src/target/source.rs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@
55
/// A description's plaintext is handed to it by reference: the default mode,
66
/// and the one every [`EncryptFrom`](super::EncryptFrom) declaration runs in.
77
/// An operation that consumes the plaintext clones it.
8+
///
9+
/// This is a mode, not a value: the enum is uninhabited, so no `Borrowed`
10+
/// ever exists and it never holds a plaintext. Its `Debug` can print nothing.
811
#[derive(Debug)]
912
pub enum Borrowed {}
1013

1114
/// A description's plaintext is handed to it by value. A single operation
1215
/// consumes it without a copy; only fan-out over it needs `Clone`.
16+
///
17+
/// Uninhabited like [`Borrowed`]: a mode that never holds the plaintext. The
18+
/// value itself lives only inside the description's closure, which has no
19+
/// `Debug`, and in the [`Pending`](super::Pending) output.
1320
#[derive(Debug)]
1421
pub enum Owned {}
1522

0 commit comments

Comments
 (0)