Function pack_with_versionstamp_for_key

Source
pub fn pack_with_versionstamp_for_key<T>(v: &T, api_version: i32) -> Vec<u8> ⓘ
where T: TuplePack,
Expand description

Pack a tuple key for the explicitly selected runtime API version.

An incomplete versionstamp appends a two-byte little-endian offset before API 520, or a four-byte offset at API 520 and later. The version must match the runtime API selected by the application, which can differ from its headers or client library version. This function does not inspect client initialization. Tuples with no incomplete stamp are packed normally, without a suffix.

This is a key operand for SetVersionstampedKey, not a legacy SetVersionstampedValue operand: before API 520, values are stamped at byte zero and cannot preserve the tuple’s type code.

§Panics

Panics if there are multiple incomplete stamps, the encoded size does not fit in u32, or a legacy key’s stamp offset does not fit in u16.

use foundationdb_tuple::{pack_with_versionstamp_for_key, Versionstamp};
let key = pack_with_versionstamp_for_key(&("event", Versionstamp::incomplete(0)), 510);
assert_eq!(&key[key.len() - 2..], &8_u16.to_le_bytes());