| 214 | } |
| 215 | |
| 216 | pub(super) fn encode_layout( |
| 217 | ops: &[FileOps], |
| 218 | content: &[u8], |
| 219 | split_ids: bool, |
| 220 | ) -> FormatResult<Vec<u8>> { |
| 221 | let c = columns(ops, content, split_ids)?; |
| 222 | let mut out = MAGIC.to_vec(); |
| 223 | out.extend(postcard::to_allocvec(&c)?); |
| 224 | if out.len() > MAX_PAYLOAD { |
| 225 | return Err(super::super::FormatError::SemanticLimitExceeded); |
| 226 | } |
| 227 | Ok(out) |
| 228 | } |
| 229 | |
| 230 | pub(super) fn columns(ops: &[FileOps], content: &[u8], split_ids: bool) -> FormatResult<Columns> { |
| 231 | if content.len() > MAX_PAYLOAD { |