| <!-- WARNING: This file is machine generated by //src/tests/fidl/source_compatibility/gen, do not edit. --> |
| |
| Note: This document covers API impact only. For more details, see the |
| [ABI compatibility page](/docs/development/languages/fidl/guides/compatibility/README.md) |
| |
| # Remove a table member |
| |
| ## Overview |
| |
| -|[init](#init)|[step 1](#step-1)|[step 2](#step-2) |
| ---|---|---|--- |
| fidl|[link](#fidl-init)||[link](#fidl-2) |
| dart|[link](#dart-init)|[link](#dart-1)| |
| go|[link](#go-init)|[link](#go-1)| |
| hlcpp|[link](#hlcpp-init)|[link](#hlcpp-1)| |
| llcpp|[link](#llcpp-init)|[link](#llcpp-1)| |
| rust|[link](#rust-init)|[link](#rust-1)| |
| |
| ## Initial State {#init} |
| |
| ### FIDL {#fidl-init} |
| |
| ```fidl |
| type Profile = table { |
| 1: timezone Timezone; |
| 2: temperature_unit TemperatureUnit; |
| 3: dark_mode bool; |
| }; |
| ``` |
| |
| ### Dart {#dart-init} |
| |
| ```dart |
| void useTable(fidllib.Profile profile) { |
| if (profile.timezone != null) { |
| print('timezone: ${profile.timezone}'); |
| } |
| if (profile.temperatureUnit != null) { |
| print('preferred unit: ${profile.temperatureUnit}'); |
| } |
| if (profile.darkMode != null) { |
| print('dark mode on: ${profile.darkMode}'); |
| } |
| profile.$unknownData?.forEach((ordinal, data) { |
| print('unknown ordinal $ordinal with bytes ${data.data}'); |
| }); |
| } |
| ``` |
| |
| ### Go {#go-init} |
| |
| ```go |
| func useTable(profile lib.Profile) { |
| if profile.HasTimezone() { |
| fmt.Printf("timezone: %s", profile.GetTimezone()) |
| } |
| if profile.HasTemperatureUnit() { |
| fmt.Printf("preferred unit: %s", profile.GetTemperatureUnit()) |
| } |
| if profile.HasDarkMode() { |
| fmt.Printf("dark mode on: %t", profile.GetDarkMode()) |
| } |
| for ord, data := range profile.GetUnknownData() { |
| fmt.Printf("unknown ordinal %d with bytes %v", ord, data.Bytes) |
| } |
| } |
| |
| ``` |
| |
| ### HLCPP {#hlcpp-init} |
| |
| ```cpp |
| void use_table(const fidl_test::Profile& profile) { |
| if (profile.has_timezone()) { |
| printf("timezone: %s", profile.timezone().c_str()); |
| } |
| if (profile.has_temperature_unit()) { |
| printf("preferred unit: %s", profile.temperature_unit().c_str()); |
| } |
| if (profile.has_dark_mode()) { |
| printf("dark mode on: %s", profile.dark_mode() ? "true" : "false"); |
| } |
| for (const auto& entry : profile.UnknownData()) { |
| printf("unknown ordinal %lu", entry.first); |
| } |
| } |
| ``` |
| |
| ### LLCPP {#llcpp-init} |
| |
| ```cpp |
| void use_table(const fidl_test::wire::Profile& profile) { |
| if (profile.has_timezone()) { |
| printf("timezone: %s", profile.timezone().data()); |
| } |
| if (profile.has_temperature_unit()) { |
| printf("preferred unit: %s", profile.temperature_unit().data()); |
| } |
| if (profile.has_dark_mode()) { |
| printf("dark mode on: %s", profile.dark_mode() ? "true" : "false"); |
| } |
| } |
| ``` |
| |
| ### Rust {#rust-init} |
| |
| ```rust |
| fn use_table(profile: &fidl_lib::Profile) { |
| if let Some(tz) = &profile.timezone { |
| println!("timezone: {:?}", tz); |
| } |
| if let Some(unit) = &profile.temperature_unit { |
| println!("preferred unit: {:?}", unit); |
| } |
| if let Some(is_on) = &profile.dark_mode { |
| println!("dark mode on: {}", is_on); |
| } |
| if let Some(data) = &profile.unknown_data { |
| for (ordinal, bytes) in data.iter() { |
| println!("unknown ordinal {} with bytes {:?}", ordinal, bytes); |
| } |
| } |
| } |
| ``` |
| |
| ## Update Source Code {#step-1} |
| |
| ### Dart {#dart-1} |
| |
| - Remove references to the soon-to-be-removed member |
| |
| ```diff |
| void useTable(fidllib.Profile profile) { |
| if (profile.timezone != null) { |
| print('timezone: ${profile.timezone}'); |
| } |
| if (profile.temperatureUnit != null) { |
| print('preferred unit: ${profile.temperatureUnit}'); |
| } |
| - if (profile.darkMode != null) { |
| - print('dark mode on: ${profile.darkMode}'); |
| - } |
| profile.$unknownData?.forEach((ordinal, data) { |
| print('unknown ordinal $ordinal with bytes ${data.data}'); |
| }); |
| } |
| |
| ``` |
| |
| ### Go {#go-1} |
| |
| - Remove references to the soon-to-be-removed member |
| |
| ```diff |
| func useTable(profile lib.Profile) { |
| if profile.HasTimezone() { |
| fmt.Printf("timezone: %s", profile.GetTimezone()) |
| } |
| if profile.HasTemperatureUnit() { |
| fmt.Printf("preferred unit: %s", profile.GetTemperatureUnit()) |
| } |
| - if profile.HasDarkMode() { |
| - fmt.Printf("dark mode on: %t", profile.GetDarkMode()) |
| - } |
| for ord, data := range profile.GetUnknownData() { |
| fmt.Printf("unknown ordinal %d with bytes %v", ord, data.Bytes) |
| } |
| } |
| |
| |
| ``` |
| |
| ### HLCPP {#hlcpp-1} |
| |
| - Remove references to the soon-to-be-removed member |
| |
| ```diff |
| void use_table(const fidl_test::Profile& profile) { |
| if (profile.has_timezone()) { |
| printf("timezone: %s", profile.timezone().c_str()); |
| } |
| if (profile.has_temperature_unit()) { |
| printf("preferred unit: %s", profile.temperature_unit().c_str()); |
| } |
| - if (profile.has_dark_mode()) { |
| - printf("dark mode on: %s", profile.dark_mode() ? "true" : "false"); |
| - } |
| for (const auto& entry : profile.UnknownData()) { |
| printf("unknown ordinal %lu", entry.first); |
| } |
| } |
| |
| ``` |
| |
| ### LLCPP {#llcpp-1} |
| |
| - Remove references to the soon-to-be-removed member |
| |
| ```diff |
| void use_table(const fidl_test::wire::Profile& profile) { |
| if (profile.has_timezone()) { |
| printf("timezone: %s", profile.timezone().data()); |
| } |
| if (profile.has_temperature_unit()) { |
| printf("preferred unit: %s", profile.temperature_unit().data()); |
| } |
| - if (profile.has_dark_mode()) { |
| - printf("dark mode on: %s", profile.dark_mode() ? "true" : "false"); |
| - } |
| } |
| |
| ``` |
| |
| ### Rust {#rust-1} |
| |
| - Remove references to the soon-to-be-removed member |
| |
| ```diff |
| fn use_table(profile: &fidl_lib::Profile) { |
| if let Some(tz) = &profile.timezone { |
| println!("timezone: {:?}", tz); |
| } |
| if let Some(unit) = &profile.temperature_unit { |
| println!("preferred unit: {:?}", unit); |
| } |
| - if let Some(is_on) = &profile.dark_mode { |
| - println!("dark mode on: {}", is_on); |
| - } |
| if let Some(data) = &profile.unknown_data { |
| for (ordinal, bytes) in data.iter() { |
| println!("unknown ordinal {} with bytes {:?}", ordinal, bytes); |
| } |
| } |
| } |
| |
| ``` |
| |
| ## Update FIDL Library {#step-2} |
| |
| - Remove the member |
| |
| ```diff |
| type Profile = table { |
| 1: timezone Timezone; |
| 2: temperature_unit TemperatureUnit; |
| - 3: dark_mode bool; |
| }; |
| |
| ``` |
| |