Fixed bounds on Bytes's associated types.

This commit is contained in:
2020-09-19 23:38:08 +01:00
parent 1b276918d3
commit aa7edaf92b

View File

@@ -1,7 +1,7 @@
//! Interface for converting various structures to and from bytes
// Imports
use std::{error::Error, fmt::Debug};
use std::error::Error;
/// Conversions to and from bytes for the game file
pub trait Bytes
@@ -9,15 +9,13 @@ where
Self: Sized,
{
/// The type of array required by this structure
///
/// *MUST* be a `[u8; N]` or `u8`
type ByteArray: ByteArray + Sized;
type ByteArray: ByteArray;
/// The error type used for the operation
type FromError: Debug + Error;
type FromError: Error;
/// The error type used for the operation
type ToError: Debug + Error;
type ToError: Error;
/// Constructs this structure from `bytes`
fn from_bytes(bytes: &Self::ByteArray) -> Result<Self, Self::FromError>;