hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
transport_builder.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_TRANSPORT_BUILDER_HPP
7 #define IROHA_TRANSPORT_BUILDER_HPP
8 
9 #include "common/result.hpp"
10 
11 namespace shared_model {
12  namespace proto {
13 
20  template <typename T, typename SV>
22  public:
23  TransportBuilder(const SV &validator = SV())
24  : stateless_validator_(validator) {}
25 
30  iroha::expected::Result<T, std::string> build(
31  typename T::TransportType transport) {
32  auto result = T(transport);
33  auto answer = stateless_validator_.validate(result);
34  if (answer.hasErrors()) {
35  return iroha::expected::makeError(answer.reason());
36  }
37  return iroha::expected::makeValue(T(std::move(transport)));
38  }
39 
40  private:
41  SV stateless_validator_;
42  };
43 
44  } // namespace proto
45 } // namespace shared_model
46 #endif // IROHA_TRANSPORT_BUILDER_HPP
iroha::expected::Result< T, std::string > build(typename T::TransportType transport)
Definition: transport_builder.hpp:30
Definition: transport_builder.hpp:21
TransportBuilder(const SV &validator=SV())
Definition: transport_builder.hpp:23
Definition: command_executor.hpp:12
#define DEPRECATED
Definition: swig_keyword_hider.hpp:15