khenaidoo | 7d3c558 | 2021-08-11 18:09:44 -0400 | [diff] [blame] | 1 | // Protocol Buffers - Google's data interchange format |
| 2 | // Copyright 2008 Google Inc. All rights reserved. |
| 3 | // https://developers.google.com/protocol-buffers/ |
| 4 | // |
| 5 | // Redistribution and use in source and binary forms, with or without |
| 6 | // modification, are permitted provided that the following conditions are |
| 7 | // met: |
| 8 | // |
| 9 | // * Redistributions of source code must retain the above copyright |
| 10 | // notice, this list of conditions and the following disclaimer. |
| 11 | // * Redistributions in binary form must reproduce the above |
| 12 | // copyright notice, this list of conditions and the following disclaimer |
| 13 | // in the documentation and/or other materials provided with the |
| 14 | // distribution. |
| 15 | // * Neither the name of Google Inc. nor the names of its |
| 16 | // contributors may be used to endorse or promote products derived from |
| 17 | // this software without specific prior written permission. |
| 18 | // |
| 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | |
| 31 | // Code generated by protoc-gen-go. DO NOT EDIT. |
| 32 | // source: google/protobuf/duration.proto |
| 33 | |
| 34 | // Package durationpb contains generated types for google/protobuf/duration.proto. |
| 35 | // |
| 36 | // The Duration message represents a signed span of time. |
| 37 | // |
| 38 | // |
| 39 | // Conversion to a Go Duration |
| 40 | // |
| 41 | // The AsDuration method can be used to convert a Duration message to a |
| 42 | // standard Go time.Duration value: |
| 43 | // |
| 44 | // d := dur.AsDuration() |
| 45 | // ... // make use of d as a time.Duration |
| 46 | // |
| 47 | // Converting to a time.Duration is a common operation so that the extensive |
| 48 | // set of time-based operations provided by the time package can be leveraged. |
| 49 | // See https://golang.org/pkg/time for more information. |
| 50 | // |
| 51 | // The AsDuration method performs the conversion on a best-effort basis. |
| 52 | // Durations with denormal values (e.g., nanoseconds beyond -99999999 and |
| 53 | // +99999999, inclusive; or seconds and nanoseconds with opposite signs) |
| 54 | // are normalized during the conversion to a time.Duration. To manually check for |
| 55 | // invalid Duration per the documented limitations in duration.proto, |
| 56 | // additionally call the CheckValid method: |
| 57 | // |
| 58 | // if err := dur.CheckValid(); err != nil { |
| 59 | // ... // handle error |
| 60 | // } |
| 61 | // |
| 62 | // Note that the documented limitations in duration.proto does not protect a |
| 63 | // Duration from overflowing the representable range of a time.Duration in Go. |
| 64 | // The AsDuration method uses saturation arithmetic such that an overflow clamps |
| 65 | // the resulting value to the closest representable value (e.g., math.MaxInt64 |
| 66 | // for positive overflow and math.MinInt64 for negative overflow). |
| 67 | // |
| 68 | // |
| 69 | // Conversion from a Go Duration |
| 70 | // |
| 71 | // The durationpb.New function can be used to construct a Duration message |
| 72 | // from a standard Go time.Duration value: |
| 73 | // |
| 74 | // dur := durationpb.New(d) |
| 75 | // ... // make use of d as a *durationpb.Duration |
| 76 | // |
| 77 | package durationpb |
| 78 | |
| 79 | import ( |
| 80 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" |
| 81 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" |
| 82 | math "math" |
| 83 | reflect "reflect" |
| 84 | sync "sync" |
| 85 | time "time" |
| 86 | ) |
| 87 | |
| 88 | // A Duration represents a signed, fixed-length span of time represented |
| 89 | // as a count of seconds and fractions of seconds at nanosecond |
| 90 | // resolution. It is independent of any calendar and concepts like "day" |
| 91 | // or "month". It is related to Timestamp in that the difference between |
| 92 | // two Timestamp values is a Duration and it can be added or subtracted |
| 93 | // from a Timestamp. Range is approximately +-10,000 years. |
| 94 | // |
| 95 | // # Examples |
| 96 | // |
| 97 | // Example 1: Compute Duration from two Timestamps in pseudo code. |
| 98 | // |
| 99 | // Timestamp start = ...; |
| 100 | // Timestamp end = ...; |
| 101 | // Duration duration = ...; |
| 102 | // |
| 103 | // duration.seconds = end.seconds - start.seconds; |
| 104 | // duration.nanos = end.nanos - start.nanos; |
| 105 | // |
| 106 | // if (duration.seconds < 0 && duration.nanos > 0) { |
| 107 | // duration.seconds += 1; |
| 108 | // duration.nanos -= 1000000000; |
| 109 | // } else if (duration.seconds > 0 && duration.nanos < 0) { |
| 110 | // duration.seconds -= 1; |
| 111 | // duration.nanos += 1000000000; |
| 112 | // } |
| 113 | // |
| 114 | // Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. |
| 115 | // |
| 116 | // Timestamp start = ...; |
| 117 | // Duration duration = ...; |
| 118 | // Timestamp end = ...; |
| 119 | // |
| 120 | // end.seconds = start.seconds + duration.seconds; |
| 121 | // end.nanos = start.nanos + duration.nanos; |
| 122 | // |
| 123 | // if (end.nanos < 0) { |
| 124 | // end.seconds -= 1; |
| 125 | // end.nanos += 1000000000; |
| 126 | // } else if (end.nanos >= 1000000000) { |
| 127 | // end.seconds += 1; |
| 128 | // end.nanos -= 1000000000; |
| 129 | // } |
| 130 | // |
| 131 | // Example 3: Compute Duration from datetime.timedelta in Python. |
| 132 | // |
| 133 | // td = datetime.timedelta(days=3, minutes=10) |
| 134 | // duration = Duration() |
| 135 | // duration.FromTimedelta(td) |
| 136 | // |
| 137 | // # JSON Mapping |
| 138 | // |
| 139 | // In JSON format, the Duration type is encoded as a string rather than an |
| 140 | // object, where the string ends in the suffix "s" (indicating seconds) and |
| 141 | // is preceded by the number of seconds, with nanoseconds expressed as |
| 142 | // fractional seconds. For example, 3 seconds with 0 nanoseconds should be |
| 143 | // encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should |
| 144 | // be expressed in JSON format as "3.000000001s", and 3 seconds and 1 |
| 145 | // microsecond should be expressed in JSON format as "3.000001s". |
| 146 | // |
| 147 | // |
| 148 | type Duration struct { |
| 149 | state protoimpl.MessageState |
| 150 | sizeCache protoimpl.SizeCache |
| 151 | unknownFields protoimpl.UnknownFields |
| 152 | |
| 153 | // Signed seconds of the span of time. Must be from -315,576,000,000 |
| 154 | // to +315,576,000,000 inclusive. Note: these bounds are computed from: |
| 155 | // 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years |
| 156 | Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"` |
| 157 | // Signed fractions of a second at nanosecond resolution of the span |
| 158 | // of time. Durations less than one second are represented with a 0 |
| 159 | // `seconds` field and a positive or negative `nanos` field. For durations |
| 160 | // of one second or more, a non-zero value for the `nanos` field must be |
| 161 | // of the same sign as the `seconds` field. Must be from -999,999,999 |
| 162 | // to +999,999,999 inclusive. |
| 163 | Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"` |
| 164 | } |
| 165 | |
| 166 | // New constructs a new Duration from the provided time.Duration. |
| 167 | func New(d time.Duration) *Duration { |
| 168 | nanos := d.Nanoseconds() |
| 169 | secs := nanos / 1e9 |
| 170 | nanos -= secs * 1e9 |
| 171 | return &Duration{Seconds: int64(secs), Nanos: int32(nanos)} |
| 172 | } |
| 173 | |
| 174 | // AsDuration converts x to a time.Duration, |
| 175 | // returning the closest duration value in the event of overflow. |
| 176 | func (x *Duration) AsDuration() time.Duration { |
| 177 | secs := x.GetSeconds() |
| 178 | nanos := x.GetNanos() |
| 179 | d := time.Duration(secs) * time.Second |
| 180 | overflow := d/time.Second != time.Duration(secs) |
| 181 | d += time.Duration(nanos) * time.Nanosecond |
| 182 | overflow = overflow || (secs < 0 && nanos < 0 && d > 0) |
| 183 | overflow = overflow || (secs > 0 && nanos > 0 && d < 0) |
| 184 | if overflow { |
| 185 | switch { |
| 186 | case secs < 0: |
| 187 | return time.Duration(math.MinInt64) |
| 188 | case secs > 0: |
| 189 | return time.Duration(math.MaxInt64) |
| 190 | } |
| 191 | } |
| 192 | return d |
| 193 | } |
| 194 | |
| 195 | // IsValid reports whether the duration is valid. |
| 196 | // It is equivalent to CheckValid == nil. |
| 197 | func (x *Duration) IsValid() bool { |
| 198 | return x.check() == 0 |
| 199 | } |
| 200 | |
| 201 | // CheckValid returns an error if the duration is invalid. |
| 202 | // In particular, it checks whether the value is within the range of |
| 203 | // -10000 years to +10000 years inclusive. |
| 204 | // An error is reported for a nil Duration. |
| 205 | func (x *Duration) CheckValid() error { |
| 206 | switch x.check() { |
| 207 | case invalidNil: |
| 208 | return protoimpl.X.NewError("invalid nil Duration") |
| 209 | case invalidUnderflow: |
| 210 | return protoimpl.X.NewError("duration (%v) exceeds -10000 years", x) |
| 211 | case invalidOverflow: |
| 212 | return protoimpl.X.NewError("duration (%v) exceeds +10000 years", x) |
| 213 | case invalidNanosRange: |
| 214 | return protoimpl.X.NewError("duration (%v) has out-of-range nanos", x) |
| 215 | case invalidNanosSign: |
| 216 | return protoimpl.X.NewError("duration (%v) has seconds and nanos with different signs", x) |
| 217 | default: |
| 218 | return nil |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | const ( |
| 223 | _ = iota |
| 224 | invalidNil |
| 225 | invalidUnderflow |
| 226 | invalidOverflow |
| 227 | invalidNanosRange |
| 228 | invalidNanosSign |
| 229 | ) |
| 230 | |
| 231 | func (x *Duration) check() uint { |
| 232 | const absDuration = 315576000000 // 10000yr * 365.25day/yr * 24hr/day * 60min/hr * 60sec/min |
| 233 | secs := x.GetSeconds() |
| 234 | nanos := x.GetNanos() |
| 235 | switch { |
| 236 | case x == nil: |
| 237 | return invalidNil |
| 238 | case secs < -absDuration: |
| 239 | return invalidUnderflow |
| 240 | case secs > +absDuration: |
| 241 | return invalidOverflow |
| 242 | case nanos <= -1e9 || nanos >= +1e9: |
| 243 | return invalidNanosRange |
| 244 | case (secs > 0 && nanos < 0) || (secs < 0 && nanos > 0): |
| 245 | return invalidNanosSign |
| 246 | default: |
| 247 | return 0 |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | func (x *Duration) Reset() { |
| 252 | *x = Duration{} |
| 253 | if protoimpl.UnsafeEnabled { |
| 254 | mi := &file_google_protobuf_duration_proto_msgTypes[0] |
| 255 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) |
| 256 | ms.StoreMessageInfo(mi) |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | func (x *Duration) String() string { |
| 261 | return protoimpl.X.MessageStringOf(x) |
| 262 | } |
| 263 | |
| 264 | func (*Duration) ProtoMessage() {} |
| 265 | |
| 266 | func (x *Duration) ProtoReflect() protoreflect.Message { |
| 267 | mi := &file_google_protobuf_duration_proto_msgTypes[0] |
| 268 | if protoimpl.UnsafeEnabled && x != nil { |
| 269 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) |
| 270 | if ms.LoadMessageInfo() == nil { |
| 271 | ms.StoreMessageInfo(mi) |
| 272 | } |
| 273 | return ms |
| 274 | } |
| 275 | return mi.MessageOf(x) |
| 276 | } |
| 277 | |
| 278 | // Deprecated: Use Duration.ProtoReflect.Descriptor instead. |
| 279 | func (*Duration) Descriptor() ([]byte, []int) { |
| 280 | return file_google_protobuf_duration_proto_rawDescGZIP(), []int{0} |
| 281 | } |
| 282 | |
| 283 | func (x *Duration) GetSeconds() int64 { |
| 284 | if x != nil { |
| 285 | return x.Seconds |
| 286 | } |
| 287 | return 0 |
| 288 | } |
| 289 | |
| 290 | func (x *Duration) GetNanos() int32 { |
| 291 | if x != nil { |
| 292 | return x.Nanos |
| 293 | } |
| 294 | return 0 |
| 295 | } |
| 296 | |
| 297 | var File_google_protobuf_duration_proto protoreflect.FileDescriptor |
| 298 | |
| 299 | var file_google_protobuf_duration_proto_rawDesc = []byte{ |
| 300 | 0x0a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, |
| 301 | 0x66, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, |
| 302 | 0x12, 0x0f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, |
| 303 | 0x66, 0x22, 0x3a, 0x0a, 0x08, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, |
| 304 | 0x07, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, |
| 305 | 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x61, 0x6e, 0x6f, 0x73, |
| 306 | 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6e, 0x61, 0x6e, 0x6f, 0x73, 0x42, 0x83, 0x01, |
| 307 | 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, |
| 308 | 0x74, 0x6f, 0x62, 0x75, 0x66, 0x42, 0x0d, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, |
| 309 | 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x31, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, |
| 310 | 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, |
| 311 | 0x75, 0x66, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x2f, 0x64, |
| 312 | 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x70, 0x62, 0xf8, 0x01, 0x01, 0xa2, 0x02, 0x03, 0x47, |
| 313 | 0x50, 0x42, 0xaa, 0x02, 0x1e, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x74, |
| 314 | 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x65, 0x6c, 0x6c, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x54, 0x79, |
| 315 | 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, |
| 316 | } |
| 317 | |
| 318 | var ( |
| 319 | file_google_protobuf_duration_proto_rawDescOnce sync.Once |
| 320 | file_google_protobuf_duration_proto_rawDescData = file_google_protobuf_duration_proto_rawDesc |
| 321 | ) |
| 322 | |
| 323 | func file_google_protobuf_duration_proto_rawDescGZIP() []byte { |
| 324 | file_google_protobuf_duration_proto_rawDescOnce.Do(func() { |
| 325 | file_google_protobuf_duration_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_protobuf_duration_proto_rawDescData) |
| 326 | }) |
| 327 | return file_google_protobuf_duration_proto_rawDescData |
| 328 | } |
| 329 | |
| 330 | var file_google_protobuf_duration_proto_msgTypes = make([]protoimpl.MessageInfo, 1) |
| 331 | var file_google_protobuf_duration_proto_goTypes = []interface{}{ |
| 332 | (*Duration)(nil), // 0: google.protobuf.Duration |
| 333 | } |
| 334 | var file_google_protobuf_duration_proto_depIdxs = []int32{ |
| 335 | 0, // [0:0] is the sub-list for method output_type |
| 336 | 0, // [0:0] is the sub-list for method input_type |
| 337 | 0, // [0:0] is the sub-list for extension type_name |
| 338 | 0, // [0:0] is the sub-list for extension extendee |
| 339 | 0, // [0:0] is the sub-list for field type_name |
| 340 | } |
| 341 | |
| 342 | func init() { file_google_protobuf_duration_proto_init() } |
| 343 | func file_google_protobuf_duration_proto_init() { |
| 344 | if File_google_protobuf_duration_proto != nil { |
| 345 | return |
| 346 | } |
| 347 | if !protoimpl.UnsafeEnabled { |
| 348 | file_google_protobuf_duration_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { |
| 349 | switch v := v.(*Duration); i { |
| 350 | case 0: |
| 351 | return &v.state |
| 352 | case 1: |
| 353 | return &v.sizeCache |
| 354 | case 2: |
| 355 | return &v.unknownFields |
| 356 | default: |
| 357 | return nil |
| 358 | } |
| 359 | } |
| 360 | } |
| 361 | type x struct{} |
| 362 | out := protoimpl.TypeBuilder{ |
| 363 | File: protoimpl.DescBuilder{ |
| 364 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), |
| 365 | RawDescriptor: file_google_protobuf_duration_proto_rawDesc, |
| 366 | NumEnums: 0, |
| 367 | NumMessages: 1, |
| 368 | NumExtensions: 0, |
| 369 | NumServices: 0, |
| 370 | }, |
| 371 | GoTypes: file_google_protobuf_duration_proto_goTypes, |
| 372 | DependencyIndexes: file_google_protobuf_duration_proto_depIdxs, |
| 373 | MessageInfos: file_google_protobuf_duration_proto_msgTypes, |
| 374 | }.Build() |
| 375 | File_google_protobuf_duration_proto = out.File |
| 376 | file_google_protobuf_duration_proto_rawDesc = nil |
| 377 | file_google_protobuf_duration_proto_goTypes = nil |
| 378 | file_google_protobuf_duration_proto_depIdxs = nil |
| 379 | } |