blob: 60f863d9741b2509eee09426eb4bb822352d7e49 [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.interface;
using zx;
/// Types of cookies CookieMaker can prep.
type CookieKind = strict enum {
/// Universal favorite.
Chocolate = 0;
/// Holiday favorite.
Gingerbread = 1;
/// Test-writer's favorite.
Snickerdoodle = 2;
};
/// An interface for a device that's able to create and deliver cookies!
@transport("Banjo")
@banjo_layout("ddk-interface")
protocol CookieMaker {
/// Asynchonously preps a cookie.
@async
Prep(struct {
cookie CookieKind;
}) -> (struct {
token uint64;
});
/// Asynchonously bakes a cookie.
/// Must only be called after preping finishes.
@async
Bake(struct {
token uint64;
time zx.time;
}) -> (struct {
s zx.status;
});
/// Synchronously deliver a cookie.
/// Must be called only after Bake finishes.
Deliver(struct {
token uint64;
}) -> (struct {
s zx.status;
});
};
/// Protocol for a baker who outsources all of it's baking duties to others.
@transport("Banjo")
@banjo_layout("ddk-protocol")
protocol Baker {
/// Registers a cookie maker device which the baker can use.
Register(resource struct {
intf client_end:CookieMaker;
}) -> ();
/// De-registers a cookie maker device when it's no longer available.
DeRegister() -> ();
};