blob: 586f868a8599e91d2eeba943dde5545290cb7be0 [file] [log] [blame]
// Copyright 2020 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.
// NOTE: This file contains the source for FIDL examples used in documentation.
// Check that associated docs are kept in sync when modifying this file. You
// can find usages by grepping for
// `gerrit_path="examples/fidl/fuchsia.examples/types.fidl"`
// [START lib]
library fuchsia.examples;
// [END lib]
// [START consts]
const uint8 BOARD_SIZE = 9;
const string NAME = "Tic-Tac-Toe";
// [END consts]
// [START bits]
bits FileMode : uint16 {
READ = 0b001;
WRITE = 0b010;
EXECUTE = 0b100;
};
// [END bits]
// TODO(fxbug.dev/65466): Make flexible bits work with libfuzzer.
[BindingsDenylist = "libfuzzer"]
// [START flexible_bits]
flexible bits FlexibleFileMode : uint16 {
READ = 0b001;
WRITE = 0b010;
EXECUTE = 0b100;
};
// [END flexible_bits]
// [START enums]
enum LocationType {
MUSEUM = 1;
AIRPORT = 2;
RESTAURANT = 3;
};
// [END enums]
// TODO(fxbug.dev/65466): Make flexible enums work with libfuzzer.
[BindingsDenylist = "libfuzzer"]
// [START flexible_enums]
flexible enum FlexibleLocationType {
MUSEUM = 1;
AIRPORT = 2;
RESTAURANT = 3;
};
// [END flexible_enums]
// [START structs]
struct Color {
uint32 id;
string:MAX_STRING_LENGTH name = "red";
};
// [END structs]
// [START unions]
union JsonValue {
1: reserved;
2: int32 int_value;
3: string:MAX_STRING_LENGTH string_value;
};
// [END unions]
// [START flexible_unions]
flexible union FlexibleJsonValue {
1: reserved;
2: int32 int_value;
3: string:MAX_STRING_LENGTH string_value;
};
// [END flexible_unions]
// [START tables]
table User {
1: reserved;
2: uint8 age;
3: string:MAX_STRING_LENGTH name;
};
// [END tables]
// [START protocols-preface]
struct GameState {
};
// [END protocols-preface]
// NOTE: a version of this protocol using error types is also used in the
// bindings reference docs, but is not tested
// [START protocols]
protocol TicTacToe {
StartGame(bool start_first);
MakeMove(uint8 row, uint8 col) -> (bool success, GameState? new_state);
-> OnOpponentMove(GameState new_state);
};
// [END protocols]