blob: e6de130cddbdd578d9b1e8d6934442f2f1ba8f61 [file]
// Copyright 2019 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 banjo.examples.rustderive;
const SMALL_ARRAY_SIZE uint32 = 8;
const LARGE_ARRAY_SIZE uint32 = 2048;
// Next three data structures intended for checking that type that doesn't derive
// PartialEq causes type depending on it to not auto-derive PartialEq
type SomeUnion = strict union {
1: bytes1 array<uint8, 8>;
2: bytes2 array<uint8, 16>;
};
type UnionParentStruct = struct {
some_union SomeUnion;
};
type UnionGrandParentStruct = struct {
field UnionParentStruct;
};
// Next three data structures are to sanity test that types still derive PartialEq/Debug
type SomeEnum = strict enum {
v1 = 1;
v2 = 2;
};
type EnumParentStruct = struct {
some_enum SomeEnum;
};
type EnumGrandParentStruct = struct {
field EnumParentStruct;
};
// Small array should auto-derive Debug/PartialEq
type SmallArrayStruct = struct {
small_array array<uint8, SMALL_ARRAY_SIZE>;
};
// Big array should not auto-derive Debug/PartialEq
type BigArrayStruct = struct {
big_array array<uint8, LARGE_ARRAY_SIZE>;
};
// Next three data structures have circular reference. Should still be able to derive
// Debug and PartialEq
type Foo = struct {
bar Bar;
};
type Bar = struct {
bar box<Foo>;
baz box<Baz>;
};
type Baz = struct {
foo box<Foo>;
bar box<Bar>;
baz box<Baz>;
};
// Next three data structures have circular reference. Unlike the above case, one struct
// cannot derive PartialEq, hence other structs cannot, either.
type Foo2 = struct {
bar Bar2;
};
type Bar2 = struct {
bar box<Foo2>;
baz box<Baz2>;
};
type Baz2 = struct {
foo box<Foo2>;
bar box<Bar2>;
baz box<Baz2>;
some_union SomeUnion;
};