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