Changing API
Let us extend the API with more functionality: we want to let clients specify a list of lines for the birthday card:
1. package com.example.birthdayservice;
3. /** Birthday service interface. */
4. interface IBirthdayService {
5. /** Generate a Happy Birthday message. */
6. String wishHappyBirthday(String name, int years, in String[] text);
7. }
This results in an updated trait definition for IBirthdayService:
1. trait IBirthdayService {
2. fn wishHappyBirthday(
3. &self,
4. name: &str,
5. years: i32,
6. text: &[String],
7. ) -> binder::Result<String>;
8. }
- Note how the
String[]in the AIDL definition is translated as a&[String]in Rust, i.e. that idiomatic Rust types are used in the generated bindings wherever possible: inarray arguments are translated to slices.outandinoutargs are translated to&mut Vec<T>.- Return values are translated to returning a
Vec<T>.
