Warning, /include/google/protobuf/any.proto is written in an unsupported language. File is not indexed.
0001 // Protocol Buffers - Google's data interchange format
0002 // Copyright 2008 Google Inc. All rights reserved.
0003 // https://developers.google.com/protocol-buffers/
0004 //
0005 // Redistribution and use in source and binary forms, with or without
0006 // modification, are permitted provided that the following conditions are
0007 // met:
0008 //
0009 // * Redistributions of source code must retain the above copyright
0010 // notice, this list of conditions and the following disclaimer.
0011 // * Redistributions in binary form must reproduce the above
0012 // copyright notice, this list of conditions and the following disclaimer
0013 // in the documentation and/or other materials provided with the
0014 // distribution.
0015 // * Neither the name of Google Inc. nor the names of its
0016 // contributors may be used to endorse or promote products derived from
0017 // this software without specific prior written permission.
0018 //
0019 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0020 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0021 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0022 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0023 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0024 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0025 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0026 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0027 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0028 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0029 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0030
0031 syntax = "proto3";
0032
0033 package google.protobuf;
0034
0035 option go_package = "google.golang.org/protobuf/types/known/anypb";
0036 option java_package = "com.google.protobuf";
0037 option java_outer_classname = "AnyProto";
0038 option java_multiple_files = true;
0039 option objc_class_prefix = "GPB";
0040 option csharp_namespace = "Google.Protobuf.WellKnownTypes";
0041
0042 // `Any` contains an arbitrary serialized protocol buffer message along with a
0043 // URL that describes the type of the serialized message.
0044 //
0045 // Protobuf library provides support to pack/unpack Any values in the form
0046 // of utility functions or additional generated methods of the Any type.
0047 //
0048 // Example 1: Pack and unpack a message in C++.
0049 //
0050 // Foo foo = ...;
0051 // Any any;
0052 // any.PackFrom(foo);
0053 // ...
0054 // if (any.UnpackTo(&foo)) {
0055 // ...
0056 // }
0057 //
0058 // Example 2: Pack and unpack a message in Java.
0059 //
0060 // Foo foo = ...;
0061 // Any any = Any.pack(foo);
0062 // ...
0063 // if (any.is(Foo.class)) {
0064 // foo = any.unpack(Foo.class);
0065 // }
0066 // // or ...
0067 // if (any.isSameTypeAs(Foo.getDefaultInstance())) {
0068 // foo = any.unpack(Foo.getDefaultInstance());
0069 // }
0070 //
0071 // Example 3: Pack and unpack a message in Python.
0072 //
0073 // foo = Foo(...)
0074 // any = Any()
0075 // any.Pack(foo)
0076 // ...
0077 // if any.Is(Foo.DESCRIPTOR):
0078 // any.Unpack(foo)
0079 // ...
0080 //
0081 // Example 4: Pack and unpack a message in Go
0082 //
0083 // foo := &pb.Foo{...}
0084 // any, err := anypb.New(foo)
0085 // if err != nil {
0086 // ...
0087 // }
0088 // ...
0089 // foo := &pb.Foo{}
0090 // if err := any.UnmarshalTo(foo); err != nil {
0091 // ...
0092 // }
0093 //
0094 // The pack methods provided by protobuf library will by default use
0095 // 'type.googleapis.com/full.type.name' as the type URL and the unpack
0096 // methods only use the fully qualified type name after the last '/'
0097 // in the type URL, for example "foo.bar.com/x/y.z" will yield type
0098 // name "y.z".
0099 //
0100 // JSON
0101 // ====
0102 // The JSON representation of an `Any` value uses the regular
0103 // representation of the deserialized, embedded message, with an
0104 // additional field `@type` which contains the type URL. Example:
0105 //
0106 // package google.profile;
0107 // message Person {
0108 // string first_name = 1;
0109 // string last_name = 2;
0110 // }
0111 //
0112 // {
0113 // "@type": "type.googleapis.com/google.profile.Person",
0114 // "firstName": <string>,
0115 // "lastName": <string>
0116 // }
0117 //
0118 // If the embedded message type is well-known and has a custom JSON
0119 // representation, that representation will be embedded adding a field
0120 // `value` which holds the custom JSON in addition to the `@type`
0121 // field. Example (for message [google.protobuf.Duration][]):
0122 //
0123 // {
0124 // "@type": "type.googleapis.com/google.protobuf.Duration",
0125 // "value": "1.212s"
0126 // }
0127 //
0128 message Any {
0129 // A URL/resource name that uniquely identifies the type of the serialized
0130 // protocol buffer message. This string must contain at least
0131 // one "/" character. The last segment of the URL's path must represent
0132 // the fully qualified name of the type (as in
0133 // `path/google.protobuf.Duration`). The name should be in a canonical form
0134 // (e.g., leading "." is not accepted).
0135 //
0136 // In practice, teams usually precompile into the binary all types that they
0137 // expect it to use in the context of Any. However, for URLs which use the
0138 // scheme `http`, `https`, or no scheme, one can optionally set up a type
0139 // server that maps type URLs to message definitions as follows:
0140 //
0141 // * If no scheme is provided, `https` is assumed.
0142 // * An HTTP GET on the URL must yield a [google.protobuf.Type][]
0143 // value in binary format, or produce an error.
0144 // * Applications are allowed to cache lookup results based on the
0145 // URL, or have them precompiled into a binary to avoid any
0146 // lookup. Therefore, binary compatibility needs to be preserved
0147 // on changes to types. (Use versioned type names to manage
0148 // breaking changes.)
0149 //
0150 // Note: this functionality is not currently available in the official
0151 // protobuf release, and it is not used for type URLs beginning with
0152 // type.googleapis.com. As of May 2023, there are no widely used type server
0153 // implementations and no plans to implement one.
0154 //
0155 // Schemes other than `http`, `https` (or the empty scheme) might be
0156 // used with implementation specific semantics.
0157 //
0158 string type_url = 1;
0159
0160 // Must be a valid serialized protocol buffer of the above specified type.
0161 bytes value = 2;
0162 }