pub struct SourceMap { /* private fields */ }Expand description
Independently retained mapping from a scoped reader to the original bytes.
This owns only range metadata, never the temporary joined bytes. Keeping it with a callback error preserves provenance after that temporary buffer and its parser-bound view disappear. Projection uses the current query’s work; retained capacity remains charged to the original account.
Implementations§
Source§impl SourceMap
impl SourceMap
Sourcepub fn try_copy_in<W: Work>(&self, work: &W) -> Result<Self>
pub fn try_copy_in<W: Work>(&self, work: &W) -> Result<Self>
Copies source metadata for an independently retained result/error. Capacity and copying are admitted by current work; neither source bytes nor parser/query references are kept. Original/Logical coordinates and physical fragment boundaries remain unchanged after either parser drops.
Sourcepub fn coordinates(&self) -> Coordinates
pub fn coordinates(&self) -> Coordinates
Whether located errors and element spans are physical or logical.
Sourcepub fn carrier(&self) -> Span
pub fn carrier(&self) -> Span
Honest physical enclosing range, not a claim of contiguous payload.
Sourcepub fn project_offset(&self, offset: u64, execution: &impl Work) -> Result<u64>
pub fn project_offset(&self, offset: u64, execution: &impl Work) -> Result<u64>
Maps a reader offset to one original physical point.
A fragment boundary belongs to the next nonempty fragment. EOF maps to the end of the last fragment, including a trailing empty fragment; an empty constructed value maps to its original contents end, before EOC. An out-of-window offset is terminal caller misuse, not document syntax.
Sourcepub fn project_span(
&self,
span: Span,
execution: &impl Work,
) -> Result<OwnedVec<Span>>
pub fn project_span( &self, span: Span, execution: &impl Work, ) -> Result<OwnedVec<Span>>
Maps a reader range to its actual disjoint physical ranges.
The returned capacity is accounted independently. No contiguous span is invented across fragment headers. A zero-length range yields one actual boundary point. Invalid endpoints are refused before work or allocation.