blob: 01d9bba28a5850aa1026392051e1568a0fc81b1b [file] [log] [blame]
// Copyright 2021 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.sys2;
/// The string identifier for a config field.
// TODO(88692,88693): Alias is in PascalCase but may need to be changed to snake_case.
alias ConfigKey = string:CONFIG_KEY_MAX_SIZE;
/// A SHA-256 hash produced over a component's config interface.
// NOTE: 32 bytes is enough to encode a SHA-256 hash, max can be grown ABI-compatibly
// TODO(88692,88693): Alias is in PascalCase but may need to be changed to snake_case.
alias ConfigChecksum = vector<uint8>:32;
/// Config keys can only consist of these many characters
const CONFIG_KEY_MAX_SIZE uint32 = 64;
/// The declaration of a component's configuration interface.
type ConfigDecl = table {
/// Fields of the component's configuration interface.
/// Currently, these fields are sorted by key, but that property
/// should not be relied on.
1: fields vector<ConfigField>:MAX;
/// Checksum over the config declaration.
2: declaration_checksum ConfigChecksum;
};
/// Declares a single config field (key + value type)
type ConfigField = table {
/// The identifier for this config field.
/// This key will be used to match overrides.
1: key ConfigKey;
/// The value type for this config field. Config values are verified
/// against this type during build time and run time.
2: value_type ConfigValueType;
};
/// Defines valid types for a config value
type ConfigValueType = flexible union {
1: bool ConfigBooleanType;
2: uint8 ConfigUnsigned8Type;
3: uint16 ConfigUnsigned16Type;
4: uint32 ConfigUnsigned32Type;
5: uint64 ConfigUnsigned64Type;
6: int8 ConfigSigned8Type;
7: int16 ConfigSigned16Type;
8: int32 ConfigSigned32Type;
9: int64 ConfigSigned64Type;
10: string ConfigStringType;
11: vector ConfigVectorType;
};
/// Type for boolean config fields
type ConfigBooleanType = table {};
/// Type for unsigned 8-bit integer config fields
type ConfigUnsigned8Type = table {};
/// Type for unsigned 16-bit integer config fields
type ConfigUnsigned16Type = table {};
/// Type for unsigned 32-bit integer config fields
type ConfigUnsigned32Type = table {};
/// Type for unsigned 64-bit integer config fields
type ConfigUnsigned64Type = table {};
/// Type for signed 8-bit integer config fields
type ConfigSigned8Type = table {};
/// Type for signed 16-bit integer config fields
type ConfigSigned16Type = table {};
/// Type for signed 32-bit integer config fields
type ConfigSigned32Type = table {};
/// Type for signed 64-bit integer config fields
type ConfigSigned64Type = table {};
/// Type for string config fields
type ConfigStringType = table {
/// Maximum size of the string
1: max_size uint32;
};
/// Type for vector config fields
type ConfigVectorType = table {
/// Maximum number of elements allowed in the vector
1: max_count uint32;
/// Type of elements stored in the vector
2: element_type ConfigVectorElementType;
};
/// Defines valid types for elements stored in a vector.
/// This is different from `ConfigValueType` because vectors cannot store vectors.
type ConfigVectorElementType = flexible union {
1: bool ConfigBooleanType;
2: uint8 ConfigUnsigned8Type;
3: uint16 ConfigUnsigned16Type;
4: uint32 ConfigUnsigned32Type;
5: uint64 ConfigUnsigned64Type;
6: int8 ConfigSigned8Type;
7: int16 ConfigSigned16Type;
8: int32 ConfigSigned32Type;
9: int64 ConfigSigned64Type;
10: string ConfigStringType;
};