2 * Copyright (c) Meta Platforms, Inc. and affiliates.
5 * This source code is licensed under both the BSD-style license (found in the
6 * LICENSE file in the root directory of this source tree) and the GPLv2 (found
7 * in the COPYING file in the root directory of this source tree).
8 * You may select, at your option, one of the above-listed licenses.
17 * The error type enum.
20 result_error_ok, /**< No error. */
21 result_error_skip, /**< This method was skipped. */
22 result_error_system_error, /**< Some internal error happened. */
23 result_error_compression_error, /**< Compression failed. */
24 result_error_decompression_error, /**< Decompression failed. */
25 result_error_round_trip_error, /**< Data failed to round trip. */
32 size_t total_size; /**< The total compressed size. */
37 * Do not access the member variables directory, use the helper functions.
40 result_error_t internal_error;
41 result_data_t internal_data;
45 * Create a result of the error type.
47 static result_t result_error(result_error_t error);
49 * Create a result of the success type.
51 static result_t result_data(result_data_t data);
54 * Check if the result is an error or skip.
56 static int result_is_error(result_t result);
58 * Check if the result error is skip.
60 static int result_is_skip(result_t result);
62 * Get the result error or okay.
64 static result_error_t result_get_error(result_t result);
66 * Get the result data. The result MUST be checked with result_is_error() first.
68 static result_data_t result_get_data(result_t result);
70 static result_t result_error(result_error_t error) {
72 .internal_error = error,
77 static result_t result_data(result_data_t data) {
79 .internal_error = result_error_ok,
80 .internal_data = data,
85 static int result_is_error(result_t result) {
86 return result_get_error(result) != result_error_ok;
89 static int result_is_skip(result_t result) {
90 return result_get_error(result) == result_error_skip;
93 static result_error_t result_get_error(result_t result) {
94 return result.internal_error;
97 char const* result_get_error_string(result_t result);
99 static result_data_t result_get_data(result_t result) {
100 return result.internal_data;