diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-09-11 16:12:21 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-09-18 13:08:08 +0200 |
commit | 446dfdbcb63af00daa3a777958419e1dfb6fc737 (patch) | |
tree | a5bbe4244083d9a467ab8d86be762fb67bd0054e /openpgp/src/parse/packet_parser_builder.rs | |
parent | 130eed7cda9f77502bbb181bfabb45934af46a8d (diff) |
openpgp: Make Parse::from_bytes polymorphic over AsRef<[u8]>.
- A drawback of this change is that currently AsRef<[u8]> is not
implemented for [u8; _], only for specific lengths. This is a
compiler limitation that may be lifted in the future. This
limitation required fixing some tests, notably those using
include_bytes!.
- Fixes #296.
Diffstat (limited to 'openpgp/src/parse/packet_parser_builder.rs')
-rw-r--r-- | openpgp/src/parse/packet_parser_builder.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/openpgp/src/parse/packet_parser_builder.rs b/openpgp/src/parse/packet_parser_builder.rs index 6fe1e518..5719ddc4 100644 --- a/openpgp/src/parse/packet_parser_builder.rs +++ b/openpgp/src/parse/packet_parser_builder.rs @@ -59,10 +59,10 @@ impl<'a> Parse<'a, PacketParserBuilder<'a>> for PacketParserBuilder<'a> { /// Creates a `PacketParserBuilder` for an OpenPGP message stored /// in the specified buffer. - fn from_bytes(bytes: &'a [u8]) -> Result<PacketParserBuilder> { + fn from_bytes<D: AsRef<[u8]> + ?Sized>(data: &'a D) -> Result<PacketParserBuilder<'a>> { PacketParserBuilder::from_buffered_reader( Box::new(buffered_reader::Memory::with_cookie( - bytes, Cookie::default()))) + data.as_ref(), Cookie::default()))) } } |