| // 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. |
| @available(added=7) |
| 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, a list of strings, or a list of objects. |
| type DictionaryValue = flexible union { |
| 1: str string:MAX_VALUE_LENGTH; |
| 2: str_vec vector<string:MAX_VALUE_LENGTH>:MAX_NUM_VALUE_ITEMS; |
| 3: obj_vec vector<Dictionary>:MAX_NUM_VALUE_ITEMS; |
| }; |