1 // Copyright 2016 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_ENUM_TRAITS_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_ENUM_TRAITS_H_ 7 8 namespace mojo { 9 10 // This must be specialized for any type |T| to be serialized/deserialized as a 11 // mojom enum |MojomType|. Each specialization needs to implement: 12 // 13 // template <> 14 // struct EnumTraits<MojomType, T> { 15 // static MojomType ToMojom(T input); 16 // 17 // // Returning false results in deserialization failure and causes the 18 // // message pipe receiving it to be disconnected. 19 // static bool FromMojom(MojomType input, T* output); 20 // }; 21 // 22 template <typename MojomType, typename T> 23 struct EnumTraits; 24 25 } // namespace mojo 26 27 #endif // MOJO_PUBLIC_CPP_BINDINGS_ENUM_TRAITS_H_ 28