Skip to content

Commit c6b4c10

Browse files
authored
impl hash for several string types (#536)
* impl hash for several string types * Update README.md
1 parent 0ad81fa commit c6b4c10

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ $ cargo add asn1 --no-default-features
3333
- `Parser` now exposes `read_explicit_element` and `read_implicit_element`
3434
methods that allow parsing EXPLICIT/IMPLICIT elements when the tag number
3535
is not known at compile time.
36+
- `PrintableString`, `Utf8String`, `BMPString`, and `UniversalString` now
37+
`#[derive(Hash)]`. ([#536](https://github.com/alex/rust-asn1/pull/536))
3638

3739
### [0.21.0]
3840

src/types.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ impl<T: Asn1Writable> SimpleAsn1Writable for OctetStringEncoded<T> {
263263
/// Type for use with `Parser.read_element` and `Writer.write_element` for
264264
/// handling ASN.1 `PrintableString`. A `PrintableString` contains an `&str`
265265
/// with only valid characers.
266-
#[derive(Clone, Debug, PartialEq, Eq)]
266+
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
267267
pub struct PrintableString<'a>(&'a str);
268268

269269
impl<'a> PrintableString<'a> {
@@ -382,7 +382,7 @@ impl SimpleAsn1Writable for IA5String<'_> {
382382

383383
/// Type for use with `Parser.read_element` and `Writer.write_element` for
384384
/// handling ASN.1 `UTF8String`.
385-
#[derive(Clone, Debug, PartialEq, Eq)]
385+
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
386386
pub struct Utf8String<'a>(&'a str);
387387

388388
impl<'a> Utf8String<'a> {
@@ -471,7 +471,7 @@ impl SimpleAsn1Writable for VisibleString<'_> {
471471
/// Type for use with `Parser.read_element` and `Writer.write_element` for
472472
/// handling ASN.1 `BMPString`. A `BMPString` contains encoded (UTF-16-BE)
473473
/// bytes which are known to be valid.
474-
#[derive(Debug, PartialEq, Clone, Eq)]
474+
#[derive(Debug, PartialEq, Clone, Eq, Hash)]
475475
pub struct BMPString<'a>(&'a [u8]);
476476

477477
impl<'a> BMPString<'a> {
@@ -521,7 +521,7 @@ impl SimpleAsn1Writable for BMPString<'_> {
521521
/// Type for use with `Parser.read_element` and `Writer.write_element` for
522522
/// handling ASN.1 `UniversalString`. A `UniversalString` contains encoded
523523
/// (UTF-32-BE) bytes which are known to be valid.
524-
#[derive(Debug, PartialEq, Clone, Eq)]
524+
#[derive(Debug, PartialEq, Clone, Eq, Hash)]
525525
pub struct UniversalString<'a>(&'a [u8]);
526526

527527
impl<'a> UniversalString<'a> {

0 commit comments

Comments
 (0)