变量

Binder for Rust supports sending parcelables directly:

birthday_service/aidl/com/example/birthdayservice/BirthdayInfo.aidl:

  1. package com.example.birthdayservice;
  2. parcelable BirthdayInfo {
  3. String name;
  4. int years;
  5. }

birthday_service/aidl/com/example/birthdayservice/IBirthdayService.aidl:

  1. import com.example.birthdayservice.BirthdayInfo;
  2. interface IBirthdayService {
  3. /** The same thing, but with a parcelable. */
  4. String wishWithInfo(in BirthdayInfo info);
  5. }

birthday_service/src/client.rs:

  1. fn main() {
  2. binder::ProcessState::start_thread_pool();
  3. let service = connect().expect("Failed to connect to BirthdayService");
  4. service.wishWithInfo(&BirthdayInfo { name: name.clone(), years })?;
  5. }