Skip to main content

Document

Struct Document 

Source
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: String

Stable, application-assigned ID, at most 128 printable ASCII characters.

§source: String

Source locator retained in citations; not opened by this library.

§text: String

Exact UTF-8 source text.

§start_line: usize

One-based offset in the original source, for application-provided fragments.

Implementations§

Source§

impl Document

Source

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

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Document

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Document

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Document

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Document

Source§

impl PartialEq for Document

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Document

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Document

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.