Skip enum variant data in compatible mode based on variant type. # Arguments `context` - The read context `variant_type` - The variant type encoded in lower 2 bits: - 0b0 = Unit variant (no data to skip) - 0b1 = Unnamed variant (tuple data) - 0b10 = Named variant (struct-like data) `type_info` - Optional type info for named variants (must be provided for 0b10)
(
context: &mut ReadContext,
variant_type: u32,
type_info: &Option<Rc<crate::TypeInfo>>,
)
| 848 | /// - 0b10 = Named variant (struct-like data) |
| 849 | /// * `type_info` - Optional type info for named variants (must be provided for 0b10) |
| 850 | pub fn skip_enum_variant( |
| 851 | context: &mut ReadContext, |
| 852 | variant_type: u32, |
| 853 | type_info: &Option<Rc<crate::TypeInfo>>, |
| 854 | ) -> Result<(), Error> { |
| 855 | match variant_type { |
| 856 | 0b0 => { |
| 857 | // Unit variant, no data to skip |
| 858 | Ok(()) |
| 859 | } |
| 860 | 0b1 => { |
| 861 | // Unnamed variant, skip tuple data (which is serialized as a collection) |
| 862 | // Tuple uses collection format but doesn't write type info, so skip directly |
| 863 | let field_type = FieldType::new(types::LIST, false, vec![unknown_field_type()]); |
| 864 | skip_collection(context, &field_type) |
| 865 | } |
| 866 | 0b10 => { |
| 867 | // Named variant, skip struct-like data using skip_struct |
| 868 | // For named variants, we need the type_info which should have been read already |
| 869 | if type_info.is_some() { |
| 870 | let type_id = type_info.as_ref().unwrap().get_type_id() as u32; |
| 871 | skip_struct(context, type_id, type_info) |
| 872 | } else { |
| 873 | // If no type_info provided, read it inline using streaming protocol |
| 874 | let type_info_rc = context.read_type_meta()?; |
| 875 | let type_id = type_info_rc.get_type_id() as u32; |
| 876 | let type_info_opt = Some(type_info_rc); |
| 877 | skip_struct(context, type_id, &type_info_opt) |
| 878 | } |
| 879 | } |
| 880 | _ => { |
| 881 | // Invalid variant type |
| 882 | Err(Error::type_error(format!( |
| 883 | "Invalid enum variant type: {}", |
| 884 | variant_type |
| 885 | ))) |
| 886 | } |
| 887 | } |
| 888 | } |
nothing calls this directly
no test coverage detected