blob: 7126c03c486d84e023d50e4a0d1f4fafbee52daf [file] [log] [blame]
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library fuchsia.data;
// Maximum number of items in a dictionary's value.
const MAX_NUM_VALUE_ITEMS uint32 = 1024;
const MAX_NUM_ENTRIES uint32 = 1024;
const MAX_KEY_LENGTH uint32 = 1024;
const MAX_VALUE_LENGTH uint32 = 1024;
/// A dictionary is a sequence of key/value pairs.
/// Keys must be unique and sorted in lexicographically increasing order.
type Dictionary = table {
// A list of dictionary entries, where each entry is a (key, value) pair.
//
// Required.
1: entries vector<DictionaryEntry>:MAX_NUM_ENTRIES;
};
/// A key/value pair in a `Dictionary`.
type DictionaryEntry = struct {
// The key for a dictionary entry.
key string:MAX_KEY_LENGTH;
// The value associated with the `key`.
value DictionaryValue:optional;
};
/// A dictionary's value is a string, or a list of strings.
type DictionaryValue = strict union {
1: str string:MAX_VALUE_LENGTH;
2: str_vec vector<string:MAX_VALUE_LENGTH>:MAX_NUM_VALUE_ITEMS;
};