Repository navigation
refactor(stack-encrypt)!: remove target::legacy #1613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: refactor/stack-encrypt-hide-expected-context
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,6 +89,41 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |
|
|
||
| ### Breaking | ||
|
|
||
| - **`target::legacy` is removed** (#1488). It held two traits, | ||
| implemented for every type, that gave the structural API a second | ||
| call syntax: `value.encrypt_into(&keyset)`, | ||
| `value.encrypt_into_with_context(&keyset, context)`, | ||
| `Target::encrypt_from(&value, &keyset, context)`, | ||
| `stored.decrypt_into(&cipher, context)`, `P::decrypt_from(stored, &cipher)` | ||
| and `P::decrypt_from_with_context(stored, &cipher, context)`. Their | ||
| names were the same as the owned traits' `EncryptInto` and | ||
| `DecryptFrom`, but they borrowed the plaintext. | ||
| - To upgrade a type that implements `EncryptTarget` or | ||
| `DecryptSource`, use the owned traits. They take the plaintext by | ||
| value. | ||
| - To upgrade a type that implements only `EncryptFrom` or | ||
| `DecryptInto`, call the cipher. The context is `T::Context`, so | ||
| convert it with `into()`: | ||
|
|
||
| | Removed call | Replacement | | ||
| | --- | --- | | ||
| | `value.encrypt_into(&keyset)` | `keyset.encrypt_as(&value, Default::default())` | | ||
| | `value.encrypt_into_with_context(&keyset, context)` | `keyset.encrypt_as(&value, context.into())` | | ||
| | `Target::encrypt_from(&value, &keyset, context)` | `keyset.encrypt_as::<_, Target>(&value, context.into())` | | ||
| | `stored.decrypt_into(&cipher, context)` | `cipher.decrypt_as(stored, context.into())` | | ||
| | `P::decrypt_from(stored, &cipher)` | `cipher.decrypt_as::<P, _>(stored, Default::default())` | | ||
| | `P::decrypt_from_with_context(stored, &cipher, context)` | `cipher.decrypt_as::<P, _>(stored, context.into())` | | ||
|
Comment on lines
+113
to
+115
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor These rows only cover a Source: code-review · claude-opus-5-5 Generated by Claude Code |
||
|
|
||
| `encrypt_as` does not name the target, so name it with a type | ||
| annotation on the result or with the turbofish shown. | ||
| - If `value` is already a reference, pass it as it is: | ||
| `keyset.encrypt_as(value, ..)`. The removed methods took the value | ||
| through method-call autoref, so a `&String` receiver encrypted a | ||
| `String`. `encrypt_as(&value, ..)` on a `&String` encrypts a | ||
| `&String` instead. Into a derived record that is a compile error. | ||
| Into `StackCipherText` it compiles, because that target accepts any | ||
| `Encrypt` source. | ||
|
|
||
| - **`target::ExpectedContext` is no longer part of the API** (#1488). It | ||
| is the check that a `#[stash(context_field)]` record runs on decrypt: | ||
| the stored context must equal the one the caller expects, if the caller | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor This now points readers to
keyset.encrypt_as, which the same plan removes (line 1990), and drops "an owned value".TextEqQueryalready derivesEncryptTarget(eql-bindings/src/v4/text.rs:455), so the surviving form today is"alice@example.com".to_owned().encrypt_into_with_context(&keyset, email.clone()), as the eql-bindings README shows.Source: code-review · claude-opus-5-5
Generated by Claude Code