Skip to content

Commit

Permalink
Add TryFrom<&[u8]> bound to Encoding::Repr (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
fjarri authored Nov 21, 2023
1 parent e4aa7a1 commit b0a566c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,12 @@ pub trait Bounded {
/// Encoding support.
pub trait Encoding: Sized {
/// Byte array representation.
type Repr: AsRef<[u8]> + AsMut<[u8]> + Copy + Clone + Sized;
type Repr: AsRef<[u8]>
+ AsMut<[u8]>
+ Copy
+ Clone
+ Sized
+ for<'a> TryFrom<&'a [u8], Error = core::array::TryFromSliceError>;

/// Decode from big endian bytes.
fn from_be_bytes(bytes: Self::Repr) -> Self;
Expand Down

0 comments on commit b0a566c

Please sign in to comment.