blob: 5f495d7f4f21a340d8219c09bfa206c5b7293a7d [file] [log] [blame]
library fidl.test.protocols;
// This is not a reference to library zx to avoid complexity in the test data.
// A local handle is defined here that contains subtypes that this test cares
// about.
type obj_type = strict enum : uint32 {
NONE = 0;
SOCKET = 14;
};
type rights = strict bits : uint32 {
TRANSFER = 1;
DUPLICATE = 2;
};
resource_definition handle : uint32 {
properties {
subtype obj_type;
rights rights;
};
};
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 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 handle;
}) -> ();
MutateSocket(resource struct {
a handle:SOCKET;
}) -> (resource struct {
b 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();
};
protocol HandleRightsProtocol {
NoResponseMethod(resource struct {
h handle:<SOCKET, rights.TRANSFER | rights.DUPLICATE>;
});
ResponseMethod(resource struct {
h handle:<SOCKET, rights.TRANSFER | rights.DUPLICATE>;
}) -> (resource struct {
h handle:<SOCKET, rights.TRANSFER>;
});
-> AnEvent(resource struct {
h handle:<SOCKET, rights.TRANSFER | 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;
});
};