| library test.protocols; |
| |
| using zx; |
| |
| closed protocol WithAndWithoutRequestResponse { |
| strict NoRequestNoResponse(); |
| strict NoRequestEmptyResponse() -> (); |
| strict NoRequestWithResponse() -> (struct { |
| ret string; |
| }); |
| strict WithRequestNoResponse(struct { |
| arg string; |
| }); |
| strict WithRequestEmptyResponse(struct { |
| arg string; |
| }) -> (); |
| strict WithRequestWithResponse(struct { |
| arg string; |
| }) -> (struct { |
| ret string; |
| }); |
| strict -> OnEmptyResponse(); |
| strict -> OnWithResponse(struct { |
| ret string; |
| }); |
| }; |
| |
| type ErrorEnum = strict enum { |
| ERR_FOO = 1; |
| ERR_BAR = 2; |
| }; |
| |
| closed protocol WithErrorSyntax { |
| strict ResponseAsStruct() -> (struct { |
| a int64; |
| b int64; |
| c int64; |
| }) error uint32; |
| strict ErrorAsPrimitive() -> () error uint32; |
| strict ErrorAsEnum() -> () error ErrorEnum; |
| strict HandleInResult() -> (resource struct { |
| h zx.Handle; |
| }) error uint32; |
| }; |
| |
| @transport("Channel") |
| closed protocol ChannelProtocol { |
| strict MethodA(struct { |
| a int64; |
| b int64; |
| }); |
| strict -> EventA(struct { |
| a int64; |
| b int64; |
| }); |
| strict MethodB(struct { |
| a int64; |
| b int64; |
| }) -> (struct { |
| result int64; |
| }); |
| strict TakeHandle(resource struct { |
| h zx.Handle; |
| }) -> (); |
| strict MutateSocket(resource struct { |
| a zx.Handle:SOCKET; |
| }) -> (resource struct { |
| b zx.Handle:SOCKET; |
| }); |
| }; |
| |
| @transport("Syscall") |
| closed protocol SyscallProtocol { |
| strict MethodC(struct { |
| a int64; |
| b int64; |
| }); |
| }; |
| |
| @discoverable |
| closed protocol DiscoverableProtocol { |
| strict Method(); |
| }; |
| |
| @discoverable(name="fake.library.FakeProtocol") |
| closed protocol AnotherDiscoverableProtocol {}; |
| |
| @discoverable(server="platform") |
| closed protocol PlatformServer {}; |
| |
| closed protocol HandleRightsProtocol { |
| strict NoResponseMethod(resource struct { |
| h zx.Handle:<SOCKET, zx.Rights.TRANSFER | zx.Rights.DUPLICATE>; |
| }); |
| strict ResponseMethod(resource struct { |
| h zx.Handle:<SOCKET, zx.Rights.TRANSFER | zx.Rights.DUPLICATE>; |
| }) -> (resource struct { |
| h zx.Handle:<SOCKET, zx.Rights.TRANSFER>; |
| }); |
| strict -> AnEvent(resource struct { |
| h zx.Handle:<SOCKET, zx.Rights.TRANSFER | zx.Rights.DUPLICATE>; |
| }); |
| }; |
| |
| type ProtocolEnds = resource struct { |
| client client_end:DiscoverableProtocol; |
| server server_end:DiscoverableProtocol; |
| client_opt client_end:<DiscoverableProtocol, optional>; |
| server_opt server_end:<DiscoverableProtocol, optional>; |
| }; |
| |
| closed protocol WithProtocolEnds { |
| strict ClientEnds(resource struct { |
| in client_end:DiscoverableProtocol; |
| }) -> (resource struct { |
| out client_end:<DiscoverableProtocol, optional>; |
| }); |
| strict ServerEnds(resource struct { |
| in server_end:<DiscoverableProtocol, optional>; |
| }) -> (resource struct { |
| out server_end:DiscoverableProtocol; |
| }); |
| strict StructContainingEnds(resource struct { |
| in ProtocolEnds; |
| }) -> (resource struct { |
| out ProtocolEnds; |
| }); |
| }; |
| |
| closed protocol ManyParameters { |
| strict Fifteen(struct { |
| p1 bool; |
| p2 bool; |
| p3 bool; |
| p4 bool; |
| p5 bool; |
| p6 bool; |
| p7 bool; |
| p8 bool; |
| p9 bool; |
| p10 bool; |
| p11 bool; |
| p12 bool; |
| p13 bool; |
| p14 bool; |
| p15 bool; |
| }); |
| }; |
| |
| type TheUnion = flexible union { |
| 1: v uint32; |
| }; |
| |
| closed protocol MethodWithUnion { |
| strict UnionMethod(struct { |
| u TheUnion; |
| }) -> (struct { |
| u TheUnion:optional; |
| }); |
| }; |