| // 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 fuchsia.app.discover; |
| |
| using fuchsia.modular; |
| using fuchsia.mem; |
| |
| const uint32 ENTITY_REFERENCE_MAX_LENGTH = 1024; |
| const uint32 MODULE_NAME_MAX_LENGTH = 512; |
| const uint32 STATE_KEY_MAX_LENGTH = 128; |
| const uint32 OUTPUT_NAME_MAX_LENGTH = 128; |
| |
| using ModuleName = string:MODULE_NAME_MAX_LENGTH; |
| using OutputName = string:OUTPUT_NAME_MAX_LENGTH; |
| using StateKey = string:STATE_KEY_MAX_LENGTH; |
| |
| [Discoverable] |
| protocol StoryModule { |
| /// Writes the `entity_reference` to the module's `output_parameter_name` |
| /// output. If no entity is provided, the output will be unset. |
| /// Return happens upon completion of a successful write. |
| WriteOutput(OutputName output_name, string:ENTITY_REFERENCE_MAX_LENGTH? entity_reference) -> () error OutputError; |
| |
| /// Starts a mod by issuing an intent to it or re-issues an intent to the mod |
| /// with the given name. |
| IssueIntent(fuchsia.modular.Intent intent, ModuleName mod_name) -> (); |
| |
| /// Writes the `instance_state` item with the given key to storage. |
| WriteInstanceState(StateKey key, fuchsia.mem.Buffer value) -> () error StoryDiscoverError; |
| |
| /// Reads the `instance_state` item with the given key from storage. |
| ReadInstanceState(StateKey key) -> (fuchsia.mem.Buffer value) error StoryDiscoverError; |
| }; |
| |
| /// Errors that can occur when writing to an output. |
| enum OutputError : int32 { |
| /// If the output doesn't match a parameter defined in the module manifest |
| /// for the action currently being handled by the module. |
| UNKNOWN_NAME = 1; |
| |
| /// If the entity reference couldn't be resolved. |
| UNKNOWN_ENTITY_REFERENCE = 2; |
| |
| /// If the entity type written doesn't match the type defined in the module |
| /// manifest for the action currently being handled by the module. |
| INVALID_ENTITY_TYPE = 3; |
| }; |