blob: edb601adf89fc10a9c82cb4b4a42000e9e311462 [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.component.decl;
/// Config keys can only consist of these many bytes
const CONFIG_KEY_MAX_SIZE uint32 = 64;
/// The string identifier for a config field.
alias ConfigKey = string:CONFIG_KEY_MAX_SIZE;
/// The checksum produced for a configuration interface.
/// Two configuration interfaces are the same if their checksums are the same.
type ConfigChecksum = flexible union {
/// A SHA-256 hash produced over a component's config interface.
1: sha256 array<uint8, 32>;
};
/// The schema of a component's configuration interface.
type ConfigSchema = table {
/// Ordered fields of the component's configuration interface.
1: fields vector<ConfigField>:MAX;
/// Checksum over the config declaration.
2: checksum ConfigChecksum;
/// Strategy used to resolve config values.
3: value_source ConfigValueSource;
};
/// Strategies available for resolving configuration values.
type ConfigValueSource = flexible union {
/// The path within the component's package at which to find config value files.
1: package_path string:MAX;
};
/// Declares a single config field (key + type)
type ConfigField = table {
/// The identifier for this config field.
/// This key will be used to match overrides.
1: key ConfigKey;
/// The type of config values. Config values are verified
/// against this layout at build time and run time.
2: type ConfigType;
};
// The type of a config value
type ConfigType = struct {
layout ConfigTypeLayout;
// This optional is not necessary, but without it,
// FIDL compilation complains because of a possible include-cycle.
// Bug: http://fxbug.dev/66350
parameters vector<LayoutParameter>:<MAX, optional>;
constraints vector<LayoutConstraint>:MAX;
};
// Defines valid type ids for config fields.
type ConfigTypeLayout = flexible enum {
BOOL = 1;
UINT8 = 2;
UINT16 = 3;
UINT32 = 4;
UINT64 = 5;
INT8 = 6;
INT16 = 7;
INT32 = 8;
INT64 = 9;
STRING = 10;
VECTOR = 11;
};
// Parameters of a given type layout
type LayoutParameter = flexible union {
// For vectors, this is the type of the nested element.
1: nested_type ConfigType;
};
// Constraints on a given type layout
type LayoutConstraint = flexible union {
// For strings, this is the maximum number of bytes allowed.
// For vectors, this is the maximum number of elements allowed.
1: max_size uint32;
};