blob: 7bcc6e369f633b5de61a205065df4fdeb8b0b749 [file] [log] [blame]
library test.protocols;
using zx;
protocol WithAndWithoutRequestResponse {
NoRequestNoResponse();
NoRequestEmptyResponse() -> ();
NoRequestWithResponse() -> (struct {
ret string;
});
WithRequestNoResponse(struct {
arg string;
});
WithRequestEmptyResponse(struct {
arg string;
}) -> ();
WithRequestWithResponse(struct {
arg string;
}) -> (struct {
ret string;
});
-> OnEmptyResponse();
-> OnWithResponse(struct {
ret string;
});
};
type ErrorEnum = strict enum {
ERR_FOO = 1;
ERR_BAR = 2;
};
protocol WithErrorSyntax {
ResponseAsStruct() -> (struct {
a int64;
b int64;
c int64;
}) error uint32;
ErrorAsPrimitive() -> (struct {}) error uint32;
ErrorAsEnum() -> (struct {}) error ErrorEnum;
HandleInResult() -> (resource struct {
h zx.handle;
}) error uint32;
};
@transport("Channel")
protocol ChannelProtocol {
MethodA(struct {
a int64;
b int64;
});
-> EventA(struct {
a int64;
b int64;
});
MethodB(struct {
a int64;
b int64;
}) -> (struct {
result int64;
});
TakeHandle(resource struct {
h zx.handle;
}) -> ();
MutateSocket(resource struct {
a zx.handle:SOCKET;
}) -> (resource struct {
b zx.handle:SOCKET;
});
};
@transport("Syscall")
protocol SyscallProtocol {
MethodC(struct {
a int64;
b int64;
});
};
protocol Transitional {
@transitional
Request(struct {
x int64;
}) -> (struct {
y int64;
});
@transitional
OneWay(struct {
x int64;
});
@transitional
-> Event(struct {
x int64;
});
};
@discoverable
protocol DiscoverableProtocol {
Method();
};
@discoverable("fake.library.FakeProtocol")
protocol AnotherDiscoverableProtocol {};
protocol HandleRightsProtocol {
NoResponseMethod(resource struct {
h zx.handle:<SOCKET, zx.rights.TRANSFER | zx.rights.DUPLICATE>;
});
ResponseMethod(resource struct {
h zx.handle:<SOCKET, zx.rights.TRANSFER | zx.rights.DUPLICATE>;
}) -> (resource struct {
h zx.handle:<SOCKET, zx.rights.TRANSFER>;
});
-> 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>;
};
protocol WithProtocolEnds {
ClientEnds(resource struct {
in client_end:DiscoverableProtocol;
}) -> (resource struct {
out client_end:<DiscoverableProtocol, optional>;
});
ServerEnds(resource struct {
in server_end:<DiscoverableProtocol, optional>;
}) -> (resource struct {
out server_end:DiscoverableProtocol;
});
StructContainingEnds(resource struct {
in ProtocolEnds;
}) -> (resource struct {
out ProtocolEnds;
});
};
protocol ManyParameters {
// TODO(fxbug.dev/76655): Support an arbitrary number of parameters in Rust.
@bindings_denylist("rust")
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;
};
protocol MethodWithUnion {
UnionMethod(struct {
u TheUnion;
}) -> (struct {
u TheUnion:optional;
});
};