-
Notifications
You must be signed in to change notification settings - Fork 216
digest: add buffering macros #1799
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
I'm a bit worried we have to list all the traits in the invocation of the macro and that consumers will drift inconsistent over time. We can't centrally add/implement a trait (like we could with the CoreWrapper or my set of macros (#1775)). |
What do you mean by "drift"? The list of traits should not change across semver-compatible releases of To make the list of traits less annoying, I plan to add several templates for the most common cases. In other words, instead of: newtype!(
/// SHA-256 hash
Sha256(..);
delegate:
Debug AlgorithmName
Clone Default Reset
BlockSizeUser OutputSizeUser HashMarker
Update FixedOutput FixedOutputReset
); We will write: newtype!(
/// SHA-256 hash
Sha256(..);
delegate_template: FixedOutputHash
); |
We've added traits in the previous cycle: #1098 (released in digest 0.10.4) We may continue to do so in the next one. Having to list the traits means we have to each consumers and bump the list everywhere and release them. |
Together with #1799 users would need to implement `AssociatedOid` manually for created newtypes. Also replaces `feature = "const-oid"` with `feature = "oid"`.
@newpavlov can we get this wrapped up? |
@tarcieri |
It would be good to either do that or get this merged ASAP |
I will try to finalize the remaining parts during this weekend. If I will not be able to do it for some reason, we can revert #1810. |
digest/src/buffer_macros/fixed.rs
Outdated
macro_rules! buffer_fixed { | ||
( | ||
$(#[$attr:meta])* | ||
$v:vis struct $name:ident$(<$gp:ident: $bound:ident>)?($core_ty:ty); |
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.
We could simplify the macro by removing the $(<$gp:ident: $bound:ident>)?
part. Currently it's used only by gost94
and skein
.
My initial intent was for this macro to support cases covered by the buffer_ct_variable
macro, but, unfortunately, the required pattern becomes annoyingly complex, so I decided against it.
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.
I've been upgrading downstream consumers of this crate (using this branch). I haven't found any usability issues.
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.
I'm a bit confused by these macros calling themselves recursively. It makes the logic somewhat hard to follow. I guess that's to avoid having separate non-reusable macros for writing the various trait impls which would need to be part of the public API?
In general I'm eager to see this landed so I guess I won't hold it up, but I did want to note I found the macro expansions a bit hard to follow due to the large number of macro match arms.
@tarcieri $(
$crate::buffer_fixed!(
impl_inner:
$name$(<$gp: $bound>)?($core_ty);
$trait_name
);
) Because it expects for Maybe someone more familiar with declarative macros could write a better macro, but right now it's the best I could do. |
anything else blocking here? |
🤷 |
) This reverts commit c48ea2a (#1810) This bring back `master` in a state that can be consumed with a `[patch.crates-io]` (see #1799 (comment))
The new macros create buffered wrapper types and replace the old wrapper types (except
CtVariableCoreWrapper
).Closes #1069