56 lines
1.7 KiB
Protocol Buffer
56 lines
1.7 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 message cannot contain non-Copy fields unless it only has one field;
|
||
|
// messages are turned into Rust structs if they have more than one field
|
||
|
// and all types bound to Javascript must be Copy
|
||
|
// - A single-field message will not be turned into a single-field struct;
|
||
|
// the field will be passed around directly instead.
|
||
|
// - 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 usdpl_template;
|
||
|
|
||
|
// The most amazing nRPC service
|
||
|
service Template {
|
||
|
// Send back the exact same message as received
|
||
|
rpc echo (EchoMessage) returns (EchoMessage);
|
||
|
|
||
|
// Hello world
|
||
|
rpc hello (NameMessage) returns (HelloResponse);
|
||
|
|
||
|
// Service version info
|
||
|
rpc version (Empty) returns (VersionMessage);
|
||
|
|
||
|
// Service name
|
||
|
rpc name (Empty) returns (NameMessage);
|
||
|
}
|
||
|
|
||
|
// The request and response message for Echo
|
||
|
message EchoMessage {
|
||
|
string msg = 1;
|
||
|
}
|
||
|
|
||
|
message NameMessage {
|
||
|
string name = 1;
|
||
|
}
|
||
|
|
||
|
message HelloResponse {
|
||
|
string phrase = 1;
|
||
|
}
|
||
|
|
||
|
message Empty {}
|
||
|
|
||
|
message VersionMessage {
|
||
|
string version = 1;
|
||
|
}
|