pub struct ByteParsedFile { /* private fields */ }Expand description
Exact source bytes and their syntax, with a separate UTF-8 analysis view.
Implementations§
Source§impl ByteParsedFile
impl ByteParsedFile
Sourcepub fn into_parts(self) -> (ParsedFile, Option<Vec<u8>>)
pub fn into_parts(self) -> (ParsedFile, Option<Vec<u8>>)
Consume the file into its UTF-8 analysis view and optional original bytes. When bytes are absent, the analysis source is the exact UTF-8 input.
Sourcepub fn source_bytes(&self) -> &[u8] ⓘ
pub fn source_bytes(&self) -> &[u8] ⓘ
Return the exact supplied bytes, including opaque comment bytes.
Sourcepub fn token_bytes(&self, index: usize) -> &[u8] ⓘ
pub fn token_bytes(&self, index: usize) -> &[u8] ⓘ
Return one retained token’s original spelling. Panics if the token index is out of bounds.
Sourcepub fn analysis_file(&self) -> &ParsedFile
pub fn analysis_file(&self) -> &ParsedFile
Return syntax and diagnostics at the original byte coordinates.
Invalid UTF-8 comment bytes appear as one-byte non-whitespace markers in
this view. Its source text is analysis input, not exact original source;
use source_bytes or token_bytes for original spelling.
Sourcepub fn line_column(&self, byte_offset: usize) -> (usize, usize)
pub fn line_column(&self, byte_offset: usize) -> (usize, usize)
Return the one-based line and column at an original byte offset.
Valid UTF-8 scalars and opaque invalid bytes each occupy one column.
CR/LF handling and boundary panics follow ParsedFile::line_column.