Kagome
Polkadot Runtime Engine in C++17
roles.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_CORE_NETWORK_TYPES_ROLES_HPP
7 #define KAGOME_CORE_NETWORK_TYPES_ROLES_HPP
8 
9 namespace kagome::network {
10 
11  union Roles {
12  struct {
16  uint8_t full : 1;
17 
21  uint8_t light : 1;
22 
26  uint8_t authority : 1;
27 
28  } flags;
29  uint8_t value;
30 
31  Roles() : value(0) {}
32  Roles(uint8_t v) : value(v) {}
33  };
34 
41  inline bool operator==(const Roles &lhs, const Roles &rhs) {
42  return lhs.value == rhs.value;
43  }
44 
52  template <class Stream,
53  typename = std::enable_if_t<Stream::is_encoder_stream>>
54  Stream &operator<<(Stream &s, const Roles &v) {
55  return s << v.value;
56  }
57 
65  template <class Stream,
66  typename = std::enable_if_t<Stream::is_decoder_stream>>
68  return s >> v.value;
69  }
70 
71 } // namespace kagome::network
72 
73 #endif // KAGOME_CORE_NETWORK_TYPES_ROLES_HPP
struct kagome::network::Roles::@11 flags
Roles(uint8_t v)
Definition: roles.hpp:32
Stream & operator>>(Stream &s, BlockAttributes &attributes)
Stream & operator<<(Stream &s, const BlockAttributes &v)
outputs object of type BlockAttributes to stream
libp2p::connection::Stream Stream
bool operator==(const NoData &lhs, const NoData &rhs)
compares two Status instances