(
context: &mut ReadContext,
len: u32,
header: u8,
remote_field_type: &FieldType,
)
| 2061 | } |
| 2062 | |
| 2063 | fn read_vec_dynamic_items<T, C>( |
| 2064 | context: &mut ReadContext, |
| 2065 | len: u32, |
| 2066 | header: u8, |
| 2067 | remote_field_type: &FieldType, |
| 2068 | ) -> Result<Vec<T>, Error> |
| 2069 | where |
| 2070 | T: 'static, |
| 2071 | C: Codec<T>, |
| 2072 | { |
| 2073 | let is_track_ref = (header & TRACKING_REF) != 0; |
| 2074 | let has_null = (header & HAS_NULL) != 0; |
| 2075 | let is_same_type = (header & IS_SAME_TYPE) != 0; |
| 2076 | let is_declared = (header & DECL_ELEMENT_TYPE) != 0; |
| 2077 | let elem_ref_mode = if is_track_ref { |
| 2078 | RefMode::Tracking |
| 2079 | } else if has_null { |
| 2080 | RefMode::NullOnly |
| 2081 | } else { |
| 2082 | RefMode::None |
| 2083 | }; |
| 2084 | let mut vec = Vec::with_capacity(check_sequence_len(context, len)?); |
| 2085 | if is_same_type { |
| 2086 | if C::is_polymorphic() { |
| 2087 | if is_declared { |
| 2088 | return Err(Error::invalid_data( |
| 2089 | "polymorphic collection element metadata must be written in the payload", |
| 2090 | )); |
| 2091 | } |
| 2092 | let type_info = context.read_any_type_info()?; |
| 2093 | for _ in 0..len { |
| 2094 | vec.push(C::read_with_type_info( |
| 2095 | context, |
| 2096 | elem_ref_mode, |
| 2097 | type_info.clone(), |
| 2098 | )?); |
| 2099 | } |
| 2100 | } else { |
| 2101 | let element_type = if is_declared { |
| 2102 | generic_field_type(remote_field_type, 0, "list")?.clone() |
| 2103 | } else { |
| 2104 | C::read_type_info_as_field_type(context)? |
| 2105 | }; |
| 2106 | for _ in 0..len { |
| 2107 | if C::is_shared_ref() { |
| 2108 | vec.push(C::read_with_mode(context, elem_ref_mode, false)?); |
| 2109 | } else { |
| 2110 | vec.push(C::read_data_with_type(context, &element_type)?); |
| 2111 | } |
| 2112 | } |
| 2113 | } |
| 2114 | } else { |
| 2115 | for _ in 0..len { |
| 2116 | vec.push(C::read_with_mode(context, elem_ref_mode, true)?); |
| 2117 | } |
| 2118 | } |
| 2119 | Ok(vec) |
| 2120 | } |
nothing calls this directly
no test coverage detected