Add missing docs to sr-primitives. (#1531)

This commit is contained in:
Tomasz Drwięga
2019-01-24 13:49:39 +01:00
committed by Bastian Köcher
parent cff0387af0
commit 2c3c4ac0e8
5 changed files with 111 additions and 20 deletions
@@ -23,9 +23,11 @@ use traits::{self, Member, DigestItem as DigestItemT, MaybeHash};
use substrate_primitives::hash::H512 as Signature;
/// Generic header digest.
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
#[cfg_attr(feature = "std", derive(Debug, Serialize))]
pub struct Digest<Item> {
/// A list of logs in the digest.
pub logs: Vec<Item>,
}
@@ -175,6 +177,7 @@ impl<Hash: Decode, AuthorityId: Decode> Decode for DigestItem<Hash, AuthorityId>
}
impl<'a, Hash: Codec + Member, AuthorityId: Codec + Member> DigestItemRef<'a, Hash, AuthorityId> {
/// Cast this digest item into `AuthoritiesChange`.
pub fn as_authorities_change(&self) -> Option<&'a [AuthorityId]> {
match *self {
DigestItemRef::AuthoritiesChange(ref authorities) => Some(authorities),
@@ -182,6 +185,7 @@ impl<'a, Hash: Codec + Member, AuthorityId: Codec + Member> DigestItemRef<'a, Ha
}
}
/// Cast this digest item into `ChangesTrieRoot`.
pub fn as_changes_trie_root(&self) -> Option<&'a Hash> {
match *self {
DigestItemRef::ChangesTrieRoot(ref changes_trie_root) => Some(changes_trie_root),