17 #ifndef ASYLO_UTIL_STATUS_HELPERS_H_ 18 #define ASYLO_UTIL_STATUS_HELPERS_H_ 22 #include "absl/strings/string_view.h" 23 #include "absl/types/optional.h" 24 #include "asylo/util/status.h" 25 #include "asylo/util/status.pb.h" 26 #include "asylo/util/status_helpers_internal.h" 27 #include "asylo/util/statusor.h" 50 template <
typename ToStatusT,
typename FromStatusT>
52 return internal::ConvertStatusImpl<ToStatusT, FromStatusT>::Convert(
91 template <
typename MessageT>
93 return internal::ProtoPayloadImpl<MessageT>::GetTypeUrl();
105 template <
typename MessageT,
typename StatusT =
Status>
107 return internal::ProtoPayloadImpl<MessageT, StatusT>::GetPayload(status);
121 template <
typename MessageT,
typename StatusT =
Status>
123 internal::ProtoPayloadImpl<MessageT, StatusT>::SetPayload(message, status);
141 template <
typename T>
155 template <
typename T>
void SetProtoPayload(const MessageT &message, StatusT &status)
Adds a payload of type MessageT to status.
Definition: status_helpers.h:122
ToStatusT ConvertStatus(const FromStatusT &from_status)
Converts a status-like object to another status type.
Definition: status_helpers.h:51
ABSL_CONST_INIT const char kStatusMoveAssignmentMsg[]
std::string GetTypeUrl()
Returns the type URL associated with a given protobuf message type.
Definition: status_helpers.h:92
absl::optional< MessageT > GetProtoPayload(const StatusT &status)
Gets the payload of type MessageT in status.
Definition: status_helpers.h:106
Status WithContext(const Status &status, absl::string_view context)
Returns the Status with the provided context prepended to its error message.
absl::StatusOr< T > WithContext(absl::StatusOr< T > status_or, absl::string_view context)
As the StatusOr<T> overload above, but for absl::StatusOr<T>.
Definition: status_helpers.h:156
StatusProto StatusToProto(const Status &status)
Exports the contents of status into a StatusProto.
Status StatusFromProto(const StatusProto &status_proto)
Returns a Status based on the contents of the given status_proto.