Note: This document covers API impact only. For more details, see the ABI compatibility page

Remove a table member

Overview

- init step 1 step 2
fidl link link
dart link link
go link link
hlcpp link link
llcpp link link
rust link link

Initial State {#init}

FIDL {#fidl-init}

  1. table Profile {
  2. 1: Timezone timezone;
  3. 2: TemperatureUnit temperature_unit;
  4. 3: bool dark_mode;
  5. };

Dart {#dart-init}

  1. void useTable(fidllib.Profile profile) {
  2. if (profile.timezone != null) {
  3. print('timezone: ${profile.timezone}');
  4. }
  5. if (profile.temperatureUnit != null) {
  6. print('preferred unit: ${profile.temperatureUnit}');
  7. }
  8. if (profile.darkMode != null) {
  9. print('dark mode on: ${profile.darkMode}');
  10. }
  11. profile.$unknownData?.forEach((ordinal, data) {
  12. print('unknown ordinal $ordinal with bytes ${data.data}');
  13. });
  14. }

Go {#go-init}

  1. func useTable(profile lib.Profile) {
  2. if profile.HasTimezone() {
  3. fmt.Printf("timezone: %s", profile.GetTimezone())
  4. }
  5. if profile.HasTemperatureUnit() {
  6. fmt.Printf("preferred unit: %s", profile.GetTemperatureUnit())
  7. }
  8. if profile.HasDarkMode() {
  9. fmt.Printf("dark mode on: %t", profile.GetDarkMode())
  10. }
  11. for ord, data := range profile.GetUnknownData() {
  12. fmt.Printf("unknown ordinal %d with bytes %v", ord, data.Bytes)
  13. }
  14. }

HLCPP {#hlcpp-init}

  1. void use_table(const fidl_test::Profile& profile) {
  2. if (profile.has_timezone()) {
  3. printf("timezone: %s", profile.timezone().c_str());
  4. }
  5. if (profile.has_temperature_unit()) {
  6. printf("preferred unit: %s", profile.temperature_unit().c_str());
  7. }
  8. if (profile.has_dark_mode()) {
  9. printf("dark mode on: %s", profile.dark_mode() ? "true" : "false");
  10. }
  11. for (const auto& entry : profile.UnknownData()) {
  12. printf("unknown ordinal %lu", entry.first);
  13. }
  14. }

LLCPP {#llcpp-init}

  1. void use_table(const fidl_test::Profile& profile) {
  2. if (profile.has_timezone()) {
  3. printf("timezone: %s", profile.timezone().data());
  4. }
  5. if (profile.has_temperature_unit()) {
  6. printf("preferred unit: %s", profile.temperature_unit().data());
  7. }
  8. if (profile.has_dark_mode()) {
  9. printf("dark mode on: %s", profile.dark_mode() ? "true" : "false");
  10. }
  11. }

Rust {#rust-init}

  1. fn use_table(profile: &fidl_lib::Profile) {
  2. if let Some(tz) = &profile.timezone {
  3. println!("timezone: {:?}", tz);
  4. }
  5. if let Some(unit) = &profile.temperature_unit {
  6. println!("preferred unit: {:?}", unit);
  7. }
  8. if let Some(is_on) = &profile.dark_mode {
  9. println!("dark mode on: {}", is_on);
  10. }
  11. if let Some(data) = &profile.unknown_data {
  12. for (ordinal, bytes) in data.iter() {
  13. println!("unknown ordinal {} with bytes {:?}", ordinal, bytes);
  14. }
  15. }
  16. }

Update Source Code {#step-1}

Dart {#dart-1}

  • Remove references to the soon-to-be-removed member
  1. void useTable(fidllib.Profile profile) {
  2. if (profile.timezone != null) {
  3. print('timezone: ${profile.timezone}');
  4. }
  5. if (profile.temperatureUnit != null) {
  6. print('preferred unit: ${profile.temperatureUnit}');
  7. }
  8. - if (profile.darkMode != null) {
  9. - print('dark mode on: ${profile.darkMode}');
  10. - }
  11. profile.$unknownData?.forEach((ordinal, data) {
  12. print('unknown ordinal $ordinal with bytes ${data.data}');
  13. });
  14. }

Go {#go-1}

  • Remove references to the soon-to-be-removed member
  1. func useTable(profile lib.Profile) {
  2. if profile.HasTimezone() {
  3. fmt.Printf("timezone: %s", profile.GetTimezone())
  4. }
  5. if profile.HasTemperatureUnit() {
  6. fmt.Printf("preferred unit: %s", profile.GetTemperatureUnit())
  7. }
  8. - if profile.HasDarkMode() {
  9. - fmt.Printf("dark mode on: %t", profile.GetDarkMode())
  10. - }
  11. for ord, data := range profile.GetUnknownData() {
  12. fmt.Printf("unknown ordinal %d with bytes %v", ord, data.Bytes)
  13. }
  14. }

HLCPP {#hlcpp-1}

  • Remove references to the soon-to-be-removed member
  1. void use_table(const fidl_test::Profile& profile) {
  2. if (profile.has_timezone()) {
  3. printf("timezone: %s", profile.timezone().c_str());
  4. }
  5. if (profile.has_temperature_unit()) {
  6. printf("preferred unit: %s", profile.temperature_unit().c_str());
  7. }
  8. - if (profile.has_dark_mode()) {
  9. - printf("dark mode on: %s", profile.dark_mode() ? "true" : "false");
  10. - }
  11. for (const auto& entry : profile.UnknownData()) {
  12. printf("unknown ordinal %lu", entry.first);
  13. }
  14. }

LLCPP {#llcpp-1}

  • Remove references to the soon-to-be-removed member
  1. void use_table(const fidl_test::Profile& profile) {
  2. if (profile.has_timezone()) {
  3. printf("timezone: %s", profile.timezone().data());
  4. }
  5. if (profile.has_temperature_unit()) {
  6. printf("preferred unit: %s", profile.temperature_unit().data());
  7. }
  8. - if (profile.has_dark_mode()) {
  9. - printf("dark mode on: %s", profile.dark_mode() ? "true" : "false");
  10. - }
  11. }

Rust {#rust-1}

  • Remove references to the soon-to-be-removed member
  1. fn use_table(profile: &fidl_lib::Profile) {
  2. if let Some(tz) = &profile.timezone {
  3. println!("timezone: {:?}", tz);
  4. }
  5. if let Some(unit) = &profile.temperature_unit {
  6. println!("preferred unit: {:?}", unit);
  7. }
  8. - if let Some(is_on) = &profile.dark_mode {
  9. - println!("dark mode on: {}", is_on);
  10. - }
  11. if let Some(data) = &profile.unknown_data {
  12. for (ordinal, bytes) in data.iter() {
  13. println!("unknown ordinal {} with bytes {:?}", ordinal, bytes);
  14. }
  15. }
  16. }

Update FIDL Library {#step-2}

  • Remove the member
  1. table Profile {
  2. 1: Timezone timezone;
  3. 2: TemperatureUnit temperature_unit;
  4. - 3: bool dark_mode;
  5. };