pub trait ReadableDocument {
// Required methods
fn read_forward(&self, off: usize) -> &[u8] ⓘ;
fn read_backward(&self, off: usize) -> &[u8] ⓘ;
}Expand description
An abstraction over reading from text containers.
Required Methods§
Sourcefn read_forward(&self, off: usize) -> &[u8] ⓘ
fn read_forward(&self, off: usize) -> &[u8] ⓘ
Read some bytes starting at (including) the given absolute offset.
§Warning
- Be lenient on inputs:
- The given offset may be out of bounds and you MUST clamp it.
- You should not assume that offsets are at grapheme cluster boundaries.
- Be strict on outputs:
- You MUST NOT break grapheme clusters across chunks.
- You MUST NOT return an empty slice unless the offset is at or beyond the end.
Sourcefn read_backward(&self, off: usize) -> &[u8] ⓘ
fn read_backward(&self, off: usize) -> &[u8] ⓘ
Read some bytes before (but not including) the given absolute offset.
§Warning
- Be lenient on inputs:
- The given offset may be out of bounds and you MUST clamp it.
- You should not assume that offsets are at grapheme cluster boundaries.
- Be strict on outputs:
- You MUST NOT break grapheme clusters across chunks.
- You MUST NOT return an empty slice unless the offset is zero.