From 96f4a30f64612faf1ddea8a0e218de39f1349777 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Tue, 8 Jan 2019 17:04:15 +1100 Subject: [PATCH] Force `Debug` and `PartialEq` on reader traits. --- beacon_chain/types/src/readers/block_reader.rs | 11 ++++++++++- beacon_chain/types/src/readers/state_reader.rs | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/beacon_chain/types/src/readers/block_reader.rs b/beacon_chain/types/src/readers/block_reader.rs index 1698a0380..91a2852ac 100644 --- a/beacon_chain/types/src/readers/block_reader.rs +++ b/beacon_chain/types/src/readers/block_reader.rs @@ -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; diff --git a/beacon_chain/types/src/readers/state_reader.rs b/beacon_chain/types/src/readers/state_reader.rs index cbbf0854c..47266bd36 100644 --- a/beacon_chain/types/src/readers/state_reader.rs +++ b/beacon_chain/types/src/readers/state_reader.rs @@ -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;