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)
| 1540 | // using EncodeDurationAscending. The remainder of the input buffer and the |
| 1541 | // decoded duration.Duration are returned. |
| 1542 | func DecodeDurationAscending(b []byte) ([]byte, duration.Duration, error) { |
| 1543 | if PeekType(b) != Duration { |
| 1544 | return nil, duration.Duration{}, errors.Errorf("did not find marker %x", b) |
| 1545 | } |
| 1546 | b = b[1:] |
| 1547 | b, sortNanos, err := DecodeVarintAscending(b) |
| 1548 | if err != nil { |
| 1549 | return b, duration.Duration{}, err |
| 1550 | } |
| 1551 | b, months, err := DecodeVarintAscending(b) |
| 1552 | if err != nil { |
| 1553 | return b, duration.Duration{}, err |
| 1554 | } |
| 1555 | b, days, err := DecodeVarintAscending(b) |
| 1556 | if err != nil { |
| 1557 | return b, duration.Duration{}, err |
| 1558 | } |
| 1559 | d, err := duration.Decode(sortNanos, months, days) |
| 1560 | if err != nil { |
| 1561 | return b, duration.Duration{}, err |
| 1562 | } |
| 1563 | return b, d, nil |
| 1564 | } |
| 1565 | |
| 1566 | // DecodeDurationDescending is the descending version of DecodeDurationAscending. |
| 1567 | func DecodeDurationDescending(b []byte) ([]byte, duration.Duration, error) { |
no test coverage detected
searching dependent graphs…