Overview
Initial State
FIDL
protocol Example {
ExistingMethod();
};
Dart
class Server extends fidllib.Example {
@override
Future<void> existingMethod() async {}
}
void client(fidllib.ExampleProxy client) async {
await client.existingMethod();
}
Go
type client struct {
addMethod *lib.ExampleWithCtxInterface
}
func (c client) test() {
c.addMethod.ExistingMethod(context.Background())
}
type server struct{}
// Assert that server implements the Example interface
var _ lib.ExampleWithCtx = &server{}
func (*server) ExistingMethod(fidl.Context) error {
return nil
}
HLCPP
class Server : public fidl_test::Example {
void ExistingMethod() final {}
};
void client(fidl_test::ExamplePtr client) { client->ExistingMethod(); }
LLCPP
class Server final : public fidl::WireServer<fidl_test::Example> {
public:
void ExistingMethod(ExistingMethodRequestView request,
ExistingMethodCompleter::Sync& completer) final {}
};
void client(fidl::WireClient<fidl_test::Example> client) { client->ExistingMethod(); }
Rust
struct ExampleFakeProxy;
impl fidl_lib::ExampleProxyInterface for ExampleFakeProxy {
fn existing_method(&self) -> Result<(), fidl::Error> {
Ok(())
}
}
async fn example_service(chan: fasync::Channel) -> Result<(), fidl::Error> {
let mut stream = fidl_lib::ExampleRequestStream::from_channel(chan);
while let Some(req) = stream.try_next().await? {
match req {
fidl_lib::ExampleRequest::ExistingMethod { .. } => {}
}
}
Ok(())
}
Update Source Code
Go
- Embed the protocol's
WithCtxTransitionBase
struct into the server type.
type client struct {
addMethod *lib.ExampleWithCtxInterface
}
func (c client) test() {
c.addMethod.ExistingMethod(context.Background())
}
- type server struct{}
+ type server struct {
+ lib.ExampleWithCtxTransitionalBase
+ }
// Assert that server implements the Example interface
var _ lib.ExampleWithCtx = &server{}
func (*server) ExistingMethod(fidl.Context) error {
return nil
}
Rust
- Add
#[allow(unreachable_patterns)]
to the server's request stream match.
- Add an underscore arm to the server's request stream match.
struct ExampleFakeProxy;
impl fidl_lib::ExampleProxyInterface for ExampleFakeProxy {
fn existing_method(&self) -> Result<(), fidl::Error> {
Ok(())
}
}
async fn example_service(chan: fasync::Channel) -> Result<(), fidl::Error> {
let mut stream = fidl_lib::ExampleRequestStream::from_channel(chan);
while let Some(req) = stream.try_next().await? {
+ #[allow(unreachable_patterns)]
match req {
fidl_lib::ExampleRequest::ExistingMethod { .. } => {}
+ _ => {}
}
}
Ok(())
}
Update FIDL Library
- Add the new method and mark it with the
[Transitional]
attribute.
protocol Example {
ExistingMethod();
+ @transitional
+ NewMethod();
};
Update Source Code
Dart
- Add the new method to protocol implementations.
- Start using the new method in client code.
class Server extends fidllib.Example {
@override
Future<void> existingMethod() async {}
+
+ @override
+ Future<void> newMethod() async {}
}
void client(fidllib.ExampleProxy client) async {
await client.existingMethod();
+ await client.newMethod();
}
Go
- Implement the new method for the server type.
- Remove the protocol's
WithCtxTransitionBase
struct from the server type.
- Start using the new method in client code.
type client struct {
addMethod *lib.ExampleWithCtxInterface
}
func (c client) test() {
c.addMethod.ExistingMethod(context.Background())
+ c.addMethod.NewMethod(context.Background())
}
- type server struct {
- lib.ExampleWithCtxTransitionalBase
- }
+ type server struct{}
// Assert that server implements the Example interface
var _ lib.ExampleWithCtx = &server{}
func (*server) ExistingMethod(fidl.Context) error {
return nil
}
+ func (*server) NewMethod(fidl.Context) error {
+ return nil
+ }
+
HLCPP
- Add the new method to protocol implementations.
- Start using the new method in client code.
class Server : public fidl_test::Example {
void ExistingMethod() final {}
+ void NewMethod() final {}
};
- void client(fidl_test::ExamplePtr client) { client->ExistingMethod(); }
+ void client(fidl_test::ExamplePtr client) {
+ client->ExistingMethod();
+ client->NewMethod();
+ }
LLCPP
- Add the new method to protocol implementations.
- Start using the new method in client code.
class Server final : public fidl::WireServer<fidl_test::Example> {
public:
void ExistingMethod(ExistingMethodRequestView request,
ExistingMethodCompleter::Sync& completer) final {}
+ void NewMethod(NewMethodRequestView request, NewMethodCompleter::Sync& completer) final {}
};
- void client(fidl::WireClient<fidl_test::Example> client) { client->ExistingMethod(); }
+ void client(fidl::WireClient<fidl_test::Example> client) {
+ client->ExistingMethod();
+ client->NewMethod();
+ }
Rust
- Add the new method to the protocol's
ProxyInterface
implementation.
- Remove
#[allow(unreachable_patterns)]
from the server's request stream match.
- Replace the underscore arm in the server's request stream match with one that handles the new method.
struct ExampleFakeProxy;
impl fidl_lib::ExampleProxyInterface for ExampleFakeProxy {
fn existing_method(&self) -> Result<(), fidl::Error> {
+ Ok(())
+ }
+ fn new_method(&self) -> Result<(), fidl::Error> {
Ok(())
}
}
async fn example_service(chan: fasync::Channel) -> Result<(), fidl::Error> {
let mut stream = fidl_lib::ExampleRequestStream::from_channel(chan);
while let Some(req) = stream.try_next().await? {
- #[allow(unreachable_patterns)]
match req {
fidl_lib::ExampleRequest::ExistingMethod { .. } => {}
- _ => {}
+ fidl_lib::ExampleRequest::NewMethod { .. } => {}
}
}
Ok(())
}
Update FIDL Library
- Remove the
[Transitional]
attribute from the new method.
protocol Example {
ExistingMethod();
- @transitional
NewMethod();
};