DecodeDurationAscending decodes a duration.Duration value which was encoded using EncodeDurationAscending. The remainder of the input buffer and the decoded duration.Duration are returned.
(b []byte)
| 1057 | // using EncodeDurationAscending. The remainder of the input buffer and the |
| 1058 | // decoded duration.Duration are returned. |
| 1059 | func DecodeDurationAscending(b []byte) ([]byte, duration.Duration, error) { |
| 1060 | if PeekType(b) != Duration { |
| 1061 | return nil, duration.Duration{}, errors.Errorf("did not find marker %x", b) |
| 1062 | } |
| 1063 | b = b[1:] |
| 1064 | b, sortNanos, err := DecodeVarintAscending(b) |
| 1065 | if err != nil { |
| 1066 | return b, duration.Duration{}, err |
| 1067 | } |
| 1068 | b, months, err := DecodeVarintAscending(b) |
| 1069 | if err != nil { |
| 1070 | return b, duration.Duration{}, err |
| 1071 | } |
| 1072 | b, days, err := DecodeVarintAscending(b) |
| 1073 | if err != nil { |
| 1074 | return b, duration.Duration{}, err |
| 1075 | } |
| 1076 | d, err := duration.Decode(sortNanos, months, days) |
| 1077 | if err != nil { |
| 1078 | return b, duration.Duration{}, err |
| 1079 | } |
| 1080 | return b, d, nil |
| 1081 | } |
| 1082 | |
| 1083 | // DecodeDurationDescending is the descending version of DecodeDurationAscending. |
| 1084 | func DecodeDurationDescending(b []byte) ([]byte, duration.Duration, error) { |
no test coverage detected
searching dependent graphs…