Skip to content

Commit

Permalink
opaque-debug: release v0.3.1 (#1054)
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov authored Mar 1, 2024
1 parent 6918595 commit dd4addd
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 24 deletions.
30 changes: 15 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions opaque-debug/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.3.1 (2024-03-01)
### Added
- Support for generic parameters ([#1053])

[#1053]: https://github.com/RustCrypto/utils/pull/1053

## 0.3.0 (2020-06-11)
3 changes: 2 additions & 1 deletion opaque-debug/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[package]
name = "opaque-debug"
version = "0.3.0"
version = "0.3.1"
authors = ["RustCrypto Developers"]
license = "MIT OR Apache-2.0"
description = "Macro for opaque Debug trait implementation"
documentation = "https://docs.rs/opaque-debug"
repository = "https://github.com/RustCrypto/utils"
edition = "2018"
readme = "README.md"
2 changes: 1 addition & 1 deletion opaque-debug/LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2018-2019 The RustCrypto Project Developers
Copyright (c) 2018-2024 The RustCrypto Project Developers

Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
Expand Down
40 changes: 40 additions & 0 deletions opaque-debug/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# [RustCrypto]: Opaque Debug

[![crate][crate-image]][crate-link]
[![Docs][docs-image]][docs-link]
[![Build Status][build-image]][build-link]
![Apache2/MIT licensed][license-image]
![Rust Version][rustc-image]
[![Project Chat][chat-image]][chat-link]

Macro for opaque Debug trait implementation.

## License

Licensed under either of:

* [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
* [MIT license](http://opensource.org/licenses/MIT)

at your option.

### Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

[//]: # (badges)

[crate-image]: https://img.shields.io/crates/v/opaque-debug.svg
[crate-link]: https://crates.io/crates/opaque-debug
[docs-image]: https://docs.rs/opaque-debug/badge.svg
[docs-link]: https://docs.rs/opaque-debug/
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
[rustc-image]: https://img.shields.io/badge/rustc-1.41+-blue.svg
[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg
[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260052-utils
[build-image]: https://github.com/RustCrypto/utils/workflows/opaque-debug/badge.svg?branch=master&event=push
[build-link]: https://github.com/RustCrypto/utils/actions/workflows/opaque-debug.yml

[//]: # (general links)

[RustCrypto]: https://github.com/rustcrypto
41 changes: 34 additions & 7 deletions opaque-debug/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,36 @@
//! Macro for opaque `Debug` trait implementation.
//! Macro for opaque [`Debug`] trait implementation.
//!
//! In many cases it's convenient to have `Debug` implementation for all crate types,
//! e.g. to allow deriving of `Debug` in user-defined structs. But at the same time, using
//! the default derive macro can be a security hazard since it cause leaking of sensitive
//! information, for example, through uncareful logging.
//!
//! This crate introduces the [`implement!`] macro which creates an opaque [`Debug`]
//! implementation, which does not expose any internal type data.
//!
//! # Examples
//! ```
//! pub struct CryptoStuff {
//! key: [u8; 16],
//! }
//!
//! opaque_debug::implement!(CryptoStuff);
//!
//! let val = CryptoStuff { key: [42; 16] };
//! assert_eq!(format!("{:?}", val), "CryptoStuff { ... }")
//! ```
//!
//! The macro also support generic paramters:
//! ```
//! pub struct GenricCryptoStuff<K> {
//! key: K,
//! }
//!
//! opaque_debug::implement!(GenricCryptoStuff<K>);
//!
//! let val = GenricCryptoStuff { key: [42u8; 16] };
//! assert_eq!(format!("{:?}", val), "GenricCryptoStuff<[u8; 16]> { ... }")
//! ```
#![no_std]
#![doc(
html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg",
Expand All @@ -19,12 +51,7 @@ macro_rules! format_params {
};
}

/// Macro for defining opaque `Debug` implementation.
///
/// It will use the following format: "StructName { ... }". While it's
/// convenient to have it (e.g. for including into other structs), it could be
/// undesirable to leak internal state, which can happen for example through
/// uncareful logging.
/// Macro for implementing an opaque `Debug` implementation.
#[macro_export]
macro_rules! implement {
($struct:ident <$($params:ident),+>) => {
Expand Down

0 comments on commit dd4addd

Please sign in to comment.