pub struct Document {
pub id: String,
pub source: String,
pub text: String,
pub start_line: usize,
}Expand description
A source document. IDs and graph relations are application metadata, never inferred authority.
Fields§
§id: StringStable, application-assigned ID, at most 128 printable ASCII characters.
source: StringSource locator retained in citations; not opened by this library.
text: StringExact UTF-8 source text.
start_line: usizeOne-based offset in the original source, for application-provided fragments.
Implementations§
Source§impl Document
impl Document
Sourcepub fn chunks_at_lines(
&self,
starts: &[usize],
) -> Result<Vec<Self>, ContextError>
pub fn chunks_at_lines( &self, starts: &[usize], ) -> Result<Vec<Self>, ContextError>
Partition exact source bytes at explicit one-based, absolute line starts.
The first chunk begins at self.start_line; starts contains only later starts,
strictly increasing. Every chunk must contain non-whitespace text. Nothing is omitted,
normalized or overlapped; LF and CRLF are preserved. IDs use original_id:L<start>.
At most 4096 chunks and 16 MiB of input are accepted. Memory for locating boundaries
is proportional to the number of chunks, not the number of lines.
A caller-owned parser chooses complete syntax units. This function checks source ranges, not language syntax, execution safety, source authority or semantic dependencies. Replace the whole source after edits so obsolete chunks are withdrawn; repair hard edges explicitly.
Source§impl Document
impl Document
Sourcepub fn new(
id: impl Into<String>,
source: impl Into<String>,
text: impl Into<String>,
) -> Self
pub fn new( id: impl Into<String>, source: impl Into<String>, text: impl Into<String>, ) -> Self
Constructs an input document. The graph validates bounds before indexing.
Sourcepub fn chunks(
&self,
max_lines: usize,
overlap_lines: usize,
) -> Result<Vec<Self>, ContextError>
pub fn chunks( &self, max_lines: usize, overlap_lines: usize, ) -> Result<Vec<Self>, ContextError>
Splits explicit text into overlapping line chunks, preserving original line numbers and UTF-8/line terminators. This is not an AST parser: choose complete symbols yourself when syntax must remain intact. At most 4096 chunks and 16 MiB of input are accepted. Replace/withdraw obsolete chunk IDs after source edits; this method does not mutate a graph.