71 lines
2.8 KiB
Plaintext
71 lines
2.8 KiB
Plaintext
// TODO: Think if the IDL should compile into a IR (Intermediate Representation)
|
|
|
|
// Identifier for this schema, every identifier should be unique, generated by the schema compiler
|
|
// so its not necessary to do this manually
|
|
tag 0563125512
|
|
|
|
// Namespacing for the package as per usual schemas do
|
|
namespace examples.thing.basic
|
|
|
|
|
|
settings {
|
|
// This option makes so messages(consequentially structs) by default do not require to specify a succession index,
|
|
// and so this makes that both caller and provider are required to communicate on the same schema version
|
|
indexed_fields = false
|
|
}
|
|
|
|
// Imports from standard library schema types or from other schemas
|
|
|
|
|
|
// Constants are immutable values that exist permanently in schema types, useful for universal references
|
|
const WORLD_COUNT u8 = 10
|
|
|
|
|
|
// A basic message structure with versioning, the default is versioned unless specified so
|
|
struct MessageVersioned {
|
|
optional str world_name: 1
|
|
str person_name: 2
|
|
}
|
|
|
|
// A basic message structure without versioning
|
|
struct Message versioned=False {
|
|
str world_name
|
|
}
|
|
|
|
|
|
// Protocol definition that can be used for RPC, IPC or anything of the likes you can turn it into.
|
|
// The »provider« setting means that this protocol should be served by a Server, or a Client, or both
|
|
// its useful for limiting who can make cals to who.
|
|
// You can still specify per function who calls who, the field is for default behavior
|
|
protocol World provider=Server {
|
|
// One-way call that only the client can do to the server, synchronous, no return
|
|
// since its synchronous, the call will still be blocking on the caller until the provider is done processing it
|
|
function hello()
|
|
|
|
// Similar to above, one-way, no return, but this time asynchronous so the caller won't wait, and the provider
|
|
// won't send a signal to the caller saying that it is done
|
|
async function hello_await()
|
|
|
|
// Two-way call, both client and server are providers and callers
|
|
async client server function hello_both()
|
|
|
|
// One-way call, asynchronous, single return, since its asynchronous and a return is specified,
|
|
// the caller has the option to await or to be blocking, since it doesn't impact the provider
|
|
async function hello_back() -> str
|
|
|
|
// Two-way call, both client and server are providers and callers, and returns a value, similar as above
|
|
async client server function hello_back_both() -> str
|
|
|
|
// Two-way call, both client and server are providers and callers, and returns a value, similar as above
|
|
// difference being a timeout is specified, so if the call process time exceeds the time til return,
|
|
// the caller will abort waiting for the response or return signal
|
|
async client server function hello_back_both() -> str: timeout_ms=1000
|
|
}
|
|
|
|
|
|
// TODO: Think what »discoverable« should mean, just like Fuchsia IDL
|
|
@discoverable
|
|
protocol OpenWorld {
|
|
}
|
|
|