EncodeDurationAscending encodes a duration.Duration value, appends it to the supplied buffer, and returns the final buffer. The encoding is guaranteed to be ordered such that if t1.Compare(t2) < 0 (or = 0 or > 0) then bytes.Compare will order them the same way after encoding.
(b []byte, d duration.Duration)
| 1025 | // be ordered such that if t1.Compare(t2) < 0 (or = 0 or > 0) then bytes.Compare |
| 1026 | // will order them the same way after encoding. |
| 1027 | func EncodeDurationAscending(b []byte, d duration.Duration) ([]byte, error) { |
| 1028 | sortNanos, months, days, err := d.Encode() |
| 1029 | if err != nil { |
| 1030 | // TODO(dan): Handle this using d.EncodeBigInt() and the |
| 1031 | // durationBigNeg/durationBigPos markers. |
| 1032 | return b, err |
| 1033 | } |
| 1034 | b = append(b, durationMarker) |
| 1035 | b = EncodeVarintAscending(b, sortNanos) |
| 1036 | b = EncodeVarintAscending(b, months) |
| 1037 | b = EncodeVarintAscending(b, days) |
| 1038 | return b, nil |
| 1039 | } |
| 1040 | |
| 1041 | // EncodeDurationDescending is the descending version of EncodeDurationAscending. |
| 1042 | func EncodeDurationDescending(b []byte, d duration.Duration) ([]byte, error) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…