| // 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. | |
| library fuchsia.examples.docs; | |
| // [START wire-format-traversal-order] | |
| type Cart = struct { | |
| items vector<Item>; | |
| }; | |
| type Item = struct { | |
| product Product; | |
| quantity uint32; | |
| }; | |
| type Product = struct { | |
| sku string; | |
| name string; | |
| description string:optional; | |
| price uint32; | |
| }; | |
| // [END wire-format-traversal-order] | |
| // [START wire-format-inlined-objects] | |
| type Region = struct { | |
| rects vector<Rect>; | |
| }; | |
| type Rect = struct { | |
| top_left Point; | |
| bottom_right Point; | |
| }; | |
| type Point = struct { | |
| x uint32; | |
| y uint32; | |
| }; | |
| // [END wire-format-inlined-objects] | |
| // [START wire-format-tables] | |
| type Value = table { | |
| 1: command int16; | |
| 2: data Circle; | |
| 3: offset float64; | |
| }; | |
| // [END wire-format-tables] | |
| // [START wire-format-unions] | |
| type UnionValue = strict union { | |
| 1: command int16; | |
| 2: data Circle; | |
| 3: offset float64; | |
| }; | |
| // [END wire-format-unions] | |
| type CreateResource = struct {}; | |
| type ReleaseResource = struct {}; | |
| // [START command] | |
| type Command = strict union { | |
| 1: create_resource CreateResource; | |
| 2: release_resource ReleaseResource; | |
| }; | |
| // [END command] | |
| // [START mode] | |
| type Mode = strict bits { | |
| READ = 1; | |
| WRITE = 2; | |
| }; | |
| // [END mode] | |
| // [START hasher] | |
| protocol Hasher { | |
| Hash(struct { | |
| value string; | |
| }) -> (struct { | |
| result array<uint8, 10>; | |
| }); | |
| }; | |
| // [END hasher] | |
| // [START example-struct] | |
| type MyRequest = struct { | |
| serial uint32; | |
| key string; | |
| options vector<uint32>; | |
| }; | |
| // [END example-struct] |