OLD | NEW |
1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
4 // | 4 // |
5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
7 // met: | 7 // met: |
8 // | 8 // |
9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 syntax = "proto3"; | 31 syntax = "proto3"; |
32 | 32 |
33 package google.protobuf; | 33 package google.protobuf; |
34 | 34 |
35 option csharp_namespace = "Google.Protobuf.WellKnownTypes"; | 35 option csharp_namespace = "Google.Protobuf.WellKnownTypes"; |
36 option go_package = "github.com/golang/protobuf/ptypes/any"; | 36 option go_package = "github.com/golang/protobuf/ptypes/any"; |
37 option java_package = "com.google.protobuf"; | 37 option java_package = "com.google.protobuf"; |
38 option java_outer_classname = "AnyProto"; | 38 option java_outer_classname = "AnyProto"; |
39 option java_multiple_files = true; | 39 option java_multiple_files = true; |
| 40 option java_generate_equals_and_hash = true; |
40 option objc_class_prefix = "GPB"; | 41 option objc_class_prefix = "GPB"; |
41 | 42 |
42 // `Any` contains an arbitrary serialized protocol buffer message along with a | 43 // `Any` contains an arbitrary serialized protocol buffer message along with a |
43 // URL that describes the type of the serialized message. | 44 // URL that describes the type of the serialized message. |
44 // | 45 // |
45 // Protobuf library provides support to pack/unpack Any values in the form | 46 // Protobuf library provides support to pack/unpack Any values in the form |
46 // of utility functions or additional generated methods of the Any type. | 47 // of utility functions or additional generated methods of the Any type. |
47 // | 48 // |
48 // Example 1: Pack and unpack a message in C++. | 49 // Example 1: Pack and unpack a message in C++. |
49 // | 50 // |
50 // Foo foo = ...; | 51 // Foo foo = ...; |
51 // Any any; | 52 // Any any; |
52 // any.PackFrom(foo); | 53 // any.PackFrom(foo); |
53 // ... | 54 // ... |
54 // if (any.UnpackTo(&foo)) { | 55 // if (any.UnpackTo(&foo)) { |
55 // ... | 56 // ... |
56 // } | 57 // } |
57 // | 58 // |
58 // Example 2: Pack and unpack a message in Java. | 59 // Example 2: Pack and unpack a message in Java. |
59 // | 60 // |
60 // Foo foo = ...; | 61 // Foo foo = ...; |
61 // Any any = Any.pack(foo); | 62 // Any any = Any.pack(foo); |
62 // ... | 63 // ... |
63 // if (any.is(Foo.class)) { | 64 // if (any.is(Foo.class)) { |
64 // foo = any.unpack(Foo.class); | 65 // foo = any.unpack(Foo.class); |
65 // } | 66 // } |
66 // | 67 // |
67 // Example 3: Pack and unpack a message in Python. | |
68 // | |
69 // foo = Foo(...) | |
70 // any = Any() | |
71 // any.Pack(foo) | |
72 // ... | |
73 // if any.Is(Foo.DESCRIPTOR): | |
74 // any.Unpack(foo) | |
75 // ... | |
76 // | |
77 // The pack methods provided by protobuf library will by default use | 68 // The pack methods provided by protobuf library will by default use |
78 // 'type.googleapis.com/full.type.name' as the type URL and the unpack | 69 // 'type.googleapis.com/full.type.name' as the type URL and the unpack |
79 // methods only use the fully qualified type name after the last '/' | 70 // methods only use the fully qualified type name after the last '/' |
80 // in the type URL, for example "foo.bar.com/x/y.z" will yield type | 71 // in the type URL, for example "foo.bar.com/x/y.z" will yield type |
81 // name "y.z". | 72 // name "y.z". |
82 // | 73 // |
83 // | 74 // |
84 // JSON | 75 // JSON |
85 // ==== | 76 // ==== |
86 // The JSON representation of an `Any` value uses the regular | 77 // The JSON representation of an `Any` value uses the regular |
(...skipping 19 matching lines...) Expand all Loading... |
106 // | 97 // |
107 // { | 98 // { |
108 // "@type": "type.googleapis.com/google.protobuf.Duration", | 99 // "@type": "type.googleapis.com/google.protobuf.Duration", |
109 // "value": "1.212s" | 100 // "value": "1.212s" |
110 // } | 101 // } |
111 // | 102 // |
112 message Any { | 103 message Any { |
113 // A URL/resource name whose content describes the type of the | 104 // A URL/resource name whose content describes the type of the |
114 // serialized protocol buffer message. | 105 // serialized protocol buffer message. |
115 // | 106 // |
116 // For URLs which use the scheme `http`, `https`, or no scheme, the | 107 // For URLs which use the schema `http`, `https`, or no schema, the |
117 // following restrictions and interpretations apply: | 108 // following restrictions and interpretations apply: |
118 // | 109 // |
119 // * If no scheme is provided, `https` is assumed. | 110 // * If no schema is provided, `https` is assumed. |
120 // * The last segment of the URL's path must represent the fully | 111 // * The last segment of the URL's path must represent the fully |
121 // qualified name of the type (as in `path/google.protobuf.Duration`). | 112 // qualified name of the type (as in `path/google.protobuf.Duration`). |
122 // The name should be in a canonical form (e.g., leading "." is | 113 // The name should be in a canonical form (e.g., leading "." is |
123 // not accepted). | 114 // not accepted). |
124 // * An HTTP GET on the URL must yield a [google.protobuf.Type][] | 115 // * An HTTP GET on the URL must yield a [google.protobuf.Type][] |
125 // value in binary format, or produce an error. | 116 // value in binary format, or produce an error. |
126 // * Applications are allowed to cache lookup results based on the | 117 // * Applications are allowed to cache lookup results based on the |
127 // URL, or have them precompiled into a binary to avoid any | 118 // URL, or have them precompiled into a binary to avoid any |
128 // lookup. Therefore, binary compatibility needs to be preserved | 119 // lookup. Therefore, binary compatibility needs to be preserved |
129 // on changes to types. (Use versioned type names to manage | 120 // on changes to types. (Use versioned type names to manage |
130 // breaking changes.) | 121 // breaking changes.) |
131 // | 122 // |
132 // Schemes other than `http`, `https` (or the empty scheme) might be | 123 // Schemas other than `http`, `https` (or the empty schema) might be |
133 // used with implementation specific semantics. | 124 // used with implementation specific semantics. |
134 // | 125 // |
135 string type_url = 1; | 126 string type_url = 1; |
136 | 127 |
137 // Must be a valid serialized protocol buffer of the above specified type. | 128 // Must be a valid serialized protocol buffer of the above specified type. |
138 bytes value = 2; | 129 bytes value = 2; |
139 } | 130 } |
OLD | NEW |