PowerTools/backend/protos/ui.proto

57 lines
1.4 KiB
Protocol Buffer

syntax = "proto3";
//
// This is a protobuf file. This is used by gRPC (and nRPC) to define the interface
// between the front-end and the back-end. Because the front-end is compiled to
// WebAssembly and has Javascript bindings, there are a few gotchas:
//
// - A zero-field message will be turned into an empty tuple ()
// - JS bindings are similar, except with JS Objects
// - Values can be streamed back- to front-end with a Rust generator stream and a JS callback function
// - Values can be streamed front- to back-end with a JS generator function and a Rust stream consumer
//
// The generated Rust module and Typescript bindings should provide a good clue as to how to pass parameters
//
package powertools;
// The most amazing nRPC service
service UserEvent {
// back-end event
rpc layout (Empty) returns (stream Interactable);
// front-end event
rpc event (stream Interaction) returns (Empty);
}
message Empty {}
message Interaction {
uint64 id = 1;
ElementValue now = 2;
}
message Interactable {
ElementType element = 2;
uint64 id = 1;
string name = 3;
string description = 4;
ElementValue value = 5;
repeated ElementValue possibleValues = 6;
}
enum ElementType {
Display = 0;
Toggle = 1;
Slider = 2;
Dropdown = 3;
Button = 4;
}
message ElementValue {
optional double number = 1;
optional string text = 2;
optional bool boolean = 3;
optional bytes payload = 4;
repeated string textList = 5;
}