A variant of decodeVarint() that does not throw on error. Useful in contexts where only part of a serialized varint may be attempted to be decoded, e.g., when a serialized varint arrives on the boundary of a network packet.

Synopsis

Declared in <folly/Varint.h>

template<class T>
Expected<uint64_t, DecodeVarintError>
tryDecodeVarint(Range<T*>& data);

Return Value

The decoded value, or a DecodeVarintError on failure.

Parameters

Name

Description

data

The range to read from; advanced past the decoded value.

Created with MrDocs