| 180 | } |
| 181 | } |
| 182 | fn reference(&mut self, bytes: &[u8], tag: u8) -> SResult<()> { |
| 183 | let next = self.c.dictionary.len(); |
| 184 | let id = if let Some(&id) = self.dictionary.get(bytes) { |
| 185 | id |
| 186 | } else { |
| 187 | self.dictionary.insert(bytes.to_vec(), next); |
| 188 | self.c.dictionary.push(bytes.to_vec()); |
| 189 | next |
| 190 | }; |
| 191 | self.c.control.push(tag); |
| 192 | delta(&mut self.c.references, &mut self.last_reference, id as u64); |
| 193 | Ok(()) |
| 194 | } |
| 195 | fn raw<T: Serialize>(&mut self, value: &T) -> SResult<()> { |
| 196 | let bytes = postcard::to_allocvec(value).map_err(|e| Error(e.to_string()))?; |
| 197 | self.reference(&bytes, 19) |