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/packet_pile.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/packet_pile.rs')
-rw-r--r-- | openpgp/src/packet_pile.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/openpgp/src/packet_pile.rs b/openpgp/src/packet_pile.rs index d5958b7c..2db68ef3 100644 --- a/openpgp/src/packet_pile.rs +++ b/openpgp/src/packet_pile.rs @@ -57,9 +57,9 @@ impl<'a> Parse<'a, PacketPile> for PacketPile { /// Deserializes the OpenPGP message stored in the provided buffer. /// /// See `from_reader` for more details and caveats. - fn from_bytes(data: &'a [u8]) -> Result<PacketPile> { + fn from_bytes<D: AsRef<[u8]> + ?Sized>(data: &'a D) -> Result<PacketPile> { let bio = buffered_reader::Memory::with_cookie( - data, Cookie::default()); + data.as_ref(), Cookie::default()); PacketPile::from_buffered_reader(Box::new(bio)) } } |