Skip to content

Commit b6c98a9

Browse files
Re-sync with internal repository (#176)
The internal and external repositories are out of sync. This Pull Request attempts to brings them back in sync by patching the GitHub repository. Please carefully review this patch. You must disable ShipIt for your project in order to merge this pull request. DO NOT IMPORT this pull request. Instead, merge it directly on GitHub using the MERGE BUTTON. Re-enable ShipIt after merging. fbshipit-source-id: 7c28df347fbe312f743317e89188f60f4d7d24d5 Co-authored-by: Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
1 parent 746eb26 commit b6c98a9

11 files changed

Lines changed: 2580 additions & 0 deletions

File tree

thrift/annotation/compat.thrift

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
include "thrift/annotation/scope.thrift"
18+
19+
package "facebook.com/thrift/annotation"
20+
21+
namespace java com.facebook.thrift.annotation_deprecated
22+
namespace android com.facebook.thrift.annotation_deprecated
23+
namespace py.asyncio facebook_thrift_asyncio.annotation.compat
24+
namespace go thrift.annotation.compat
25+
namespace py thrift.annotation.compat
26+
27+
/**
28+
* Enumeration for coding error actions.
29+
* Used for handling malformed UTF-8 bytes.
30+
*/
31+
enum CodingErrorAction {
32+
/**
33+
* Default behavior of the languages.
34+
* Pythons default is report, java is replacing malformed
35+
* bytes, cpp skips validation and ignores malformed bytes.
36+
*/
37+
Legacy = 0,
38+
/**
39+
* A decode error is thrown when the bytes are malformed.
40+
* Default behavior in Thrift v1.
41+
*/
42+
Report = 1,
43+
}
44+
45+
/**
46+
* Enables compatibility on string and binary types. When target data
47+
* type is string, UTF-8 byte sequence is validated. If it is invalid,
48+
* one of the CodingErrorAction is taken.
49+
*/
50+
@scope.Program
51+
@scope.Structured
52+
@scope.Field
53+
@scope.Typedef
54+
struct Strings {
55+
1: CodingErrorAction onInvalidUtf8;
56+
}
57+
58+
@Strings{onInvalidUtf8 = CodingErrorAction.Report}
59+
@scope.Transitive
60+
struct Utf8 {}
61+
62+
@Strings{onInvalidUtf8 = CodingErrorAction.Legacy}
63+
@scope.Transitive
64+
struct LegacyString {}
65+
66+
/**
67+
* Enumeration for enum types.
68+
*/
69+
enum EnumType {
70+
/**
71+
* Default enum type of the languages in Thrift v0.
72+
* C++ default is open, Java is closed.
73+
*/
74+
Legacy = 0,
75+
/**
76+
* Enum is defined as open enum type.
77+
* A new enum value UNRECOGNIZED is added to the enum for the values outside the defined range.
78+
* Unrecognized values are stored as its underlying integer value and can be retrieved.
79+
* Default behavior in Thrift v1.
80+
*/
81+
Open = 1,
82+
}
83+
84+
/**
85+
* Enables compatibility on enums.
86+
*/
87+
@scope.Program
88+
@scope.Enum
89+
struct Enums {
90+
1: EnumType type;
91+
}

0 commit comments

Comments
 (0)