Force Debug and PartialEq on reader traits.

This commit is contained in:
Paul Hauner 2019-01-08 17:04:15 +11:00
parent 3876e29f6e
commit 96f4a30f64
No known key found for this signature in database
GPG Key ID: 303E4494BB28068C
2 changed files with 20 additions and 2 deletions

View File

@ -1,6 +1,15 @@
use crate::{BeaconBlock, Hash256};
use std::fmt::Debug;
pub trait BeaconBlockReader {
/// The `BeaconBlockReader` provides interfaces for reading a subset of fields of a `BeaconBlock`.
///
/// The purpose of this trait is to allow reading from either;
/// - a standard `BeaconBlock` struct, or
/// - a SSZ serialized byte array.
///
/// Note: presently, direct SSZ reading has not been implemented so this trait is being used for
/// "future proofing".
pub trait BeaconBlockReader: Debug + PartialEq {
fn slot(&self) -> u64;
fn parent_root(&self) -> Hash256;
fn state_root(&self) -> Hash256;

View File

@ -1,6 +1,15 @@
use crate::{BeaconState, Hash256};
use std::fmt::Debug;
pub trait BeaconStateReader {
/// The `BeaconStateReader` provides interfaces for reading a subset of fields of a `BeaconState`.
///
/// The purpose of this trait is to allow reading from either;
/// - a standard `BeaconState` struct, or
/// - a SSZ serialized byte array.
///
/// Note: presently, direct SSZ reading has not been implemented so this trait is being used for
/// "future proofing".
pub trait BeaconStateReader: Debug + PartialEq {
fn slot(&self) -> u64;
fn canonical_root(&self) -> Hash256;
fn into_beacon_state(self) -> Option<BeaconState>;