Skip to content

Commit ff7517c

Browse files
committed
docs(stack-encrypt): rewrite the ExpectedContext docs in plain language
The docs that this change added now say who passes what, and what the record checks, in short sentences. The JSON document's decrypt docs list the two cases a caller has.
1 parent 317b687 commit ff7517c

4 files changed

Lines changed: 21 additions & 15 deletions

File tree

‎packages/eql/crates/eql-bindings/src/v4/json_tree.rs‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -514,10 +514,13 @@ impl EncryptFrom<Value> for JsonTreeDocument {
514514
}
515515
}
516516

517-
/// Opens to the plaintext document, under the stored identifier. A caller
518-
/// that passes the column it expects, as a `NonEmpty<Identifier>`, has the
519-
/// stored identifier checked against it before any key is requested. A
520-
/// caller that passes nothing opens under the stored identifier unchecked.
517+
/// Decrypts to the plaintext document, under the stored identifier.
518+
///
519+
/// - If you pass the column you expect, as a `NonEmpty<Identifier>`, the
520+
/// stored identifier must equal it. The check runs before any key is
521+
/// requested.
522+
/// - If you pass nothing, the document decrypts under the stored
523+
/// identifier, without that check.
521524
impl DecryptInto<Value> for JsonTreeDocument {
522525
type Context = ExpectedContext<Identifier>;
523526
fn decryption<K: 'static>(self, context: Self::Context) -> Decryption<Value, K> {

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -861,10 +861,11 @@ impl DeclaredContext {
861861
/// descriptor is HMAC'd into the tag, so altering a stored identifier makes
862862
/// the retrieve fail rather than succeed, and nobody reaches a key they are
863863
/// not entitled to. See ADR-0004.
864-
// Hidden here, on the definition, and not only on the re-export. rustc
865-
// reads this attribute when it lists the types that implement a trait in a
866-
// compile error, and rustdoc reads it when another crate's docs name the
867-
// type. On the re-export alone, the type still showed in both.
864+
// `#[doc(hidden)]` must be on this definition, and not only on the
865+
// re-export. rustc reads the attribute here when a compile error lists the
866+
// types that implement a trait. rustdoc reads it here when the docs of
867+
// another crate name the type. With the attribute on the re-export alone,
868+
// both still showed the type.
868869
#[doc(hidden)]
869870
#[derive(Clone, Debug)]
870871
pub struct ExpectedContext<T>(Option<NonEmpty<T>>);

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,12 @@ pub mod transcode;
184184
mod tuples;
185185

186186
pub(crate) use self::core::{bind_pending, seal_pending};
187-
/// The check a `#[stash(context_field)]` record runs on decrypt. It is not
188-
/// part of the API: the derives and the EQL types name it, and a caller
189-
/// passes a `NonEmpty<T>` or nothing. It is public only so that code the
190-
/// derives emit in another crate can name it. The definition is hidden too.
187+
/// The check that a `#[stash(context_field)]` record runs on decrypt.
188+
///
189+
/// `ExpectedContext` is not part of the API. Only the derives and the EQL
190+
/// types name it, and a caller passes a `NonEmpty<T>` or nothing. The type
191+
/// is public only because the derives emit code in other crates that
192+
/// names it. The definition is hidden too.
191193
#[doc(hidden)]
192194
pub use context::ExpectedContext;
193195
pub use context::{

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ pub trait EncryptFrom<S>: Sized + 'static {
6666
/// ciphertext and its context, and [`open`] describes the rest. A query-only
6767
/// target (terms alone) has no implementation.
6868
pub trait DecryptInto<P>: Sized {
69-
/// What a caller supplies to open the target. A record that stores its
70-
/// context converts from `()` or from the `NonEmpty<T>` the caller
71-
/// believes it is opening.
69+
/// The context that a caller passes to decrypt the target. For a
70+
/// record that stores its context, the caller passes `()`, or the
71+
/// `NonEmpty<T>` that the caller expects the record to store.
7272
type Context;
7373
/// The description the cipher executes to recover `P`.
7474
fn decryption<K: 'static>(self, context: Self::Context) -> Decryption<P, K>;

0 commit comments

Comments
 (0)