| 129 | } |
| 130 | |
| 131 | fn make_column(view: &View<'_>, content: &[u8], i: usize, mut method: u8) -> Result<Column> { |
| 132 | let raw = view.columns()[i]; |
| 133 | if method == 8 { |
| 134 | method = match i { |
| 135 | 1 => 5, |
| 136 | 7 => 7, |
| 137 | 8 => 6, |
| 138 | _ => 0, |
| 139 | }; |
| 140 | } |
| 141 | if method == 10 { |
| 142 | method = match i { |
| 143 | 1 => 9, |
| 144 | 7 => 7, |
| 145 | _ => 0, |
| 146 | }; |
| 147 | } |
| 148 | let actual = if !numeric(i) || raw.is_empty() { |
| 149 | 0 |
| 150 | } else { |
| 151 | match method { |
| 152 | 5 if i != 1 => 0, |
| 153 | 6 if i != 8 => 0, |
| 154 | 7 if i != 7 => 0, |
| 155 | 9 if i != 1 => 0, |
| 156 | _ => method, |
| 157 | } |
| 158 | }; |
| 159 | let data = match actual { |
| 160 | 0..=4 => transforms::encode(actual, raw)?, |
| 161 | 5 => control::split(raw)?, |
| 162 | 6 => context::split_references(view)?, |
| 163 | 7 => context::predict_kinds(view, content)?, |
| 164 | 9 => lengths::split(view, content)?, |
| 165 | _ => anyhow::bail!("unknown candidate"), |
| 166 | }; |
| 167 | Ok(Column { |
| 168 | method: actual, |
| 169 | raw_len: raw.len().try_into()?, |
| 170 | data, |
| 171 | }) |
| 172 | } |
| 173 | |
| 174 | fn encode_frame(view: &View<'_>, content: &[u8], method: Option<u8>) -> Result<Vec<u8>> { |
| 175 | let mut columns = vec![]; |