| // 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 uint32 MAX_NUM_VALUE_ITEMS = 1024; |
| const uint32 MAX_NUM_ENTRIES = 1024; |
| const uint32 MAX_KEY_LENGTH = 1024; |
| const uint32 MAX_VALUE_LENGTH = 1024; |
| |
| /// A dictionary is a sequence of key/value pairs. |
| /// Keys must be unique and sorted in lexicographically increasing order. |
| table Dictionary { |
| // A list of dictionary entries, where each entry is a (key, value) pair. |
| // |
| // Required. |
| 1: vector<DictionaryEntry>:MAX_NUM_ENTRIES entries; |
| }; |
| |
| /// A key/value pair in a `Dictionary`. |
| struct DictionaryEntry { |
| // The key for a dictionary entry. |
| string:MAX_KEY_LENGTH key; |
| |
| // The value associated with the `key`. |
| DictionaryValue? value; |
| }; |
| |
| /// A dictionary's value is a string, or a list of strings. |
| union DictionaryValue { |
| 1: string:MAX_VALUE_LENGTH str; |
| 2: vector<string:MAX_VALUE_LENGTH>:MAX_NUM_VALUE_ITEMS str_vec; |
| }; |