pub fn chunk(doc: &DocValue, op: ChunkOp) -> Vec<DocChunk>Expand description
Split a decoded doc into DocChunks according to op.
Every chunk preserves its source byte offsets and heading path, so the
resulting chunks round-trip through the general-purpose codecs as ordinary
document slices. See ChunkOp for the available strategies.
ยงExamples
use sim_codec_doc::{ChunkOp, chunk, decode_document};
let doc = decode_document("abcdef");
let chunks = chunk(&doc, ChunkOp::Fixed(2));
assert_eq!(chunks.len(), 3);
assert_eq!(chunks[0].text, "ab");
assert_eq!((chunks[0].start, chunks[0].end), (0, 2));