pub struct PreparedSource<'source> { /* private fields */ }Expand description
An immutable source admitted by the caller-thread guard scan.
Private fields bind the handle to its borrowed path and text. Reading counts starts no worker or native lexer. Its consuming parse methods use that same text without repeating the guard scan. Admission is not syntax validation and does not establish a complete native heap or work bound.
Implementations§
Source§impl<'source> PreparedSource<'source>
impl<'source> PreparedSource<'source>
Sourcepub const fn token_count(&self) -> usize
pub const fn token_count(&self) -> usize
Units compared against the guard’s file-token limit.
Numeric guard runs can fuse native leaves; this is not a native-node count.
Sourcepub const fn recursion(&self) -> usize
pub const fn recursion(&self) -> usize
The highest additive recursion counter reached by the guard scan.
Sourcepub const fn native_token_bound(&self) -> usize
pub const fn native_token_bound(&self) -> usize
Upper bound on complete native token-tree nodes if lexing succeeds.
At most three native nodes arise per guard unit; source bytes separately bound documentation lowering at twice their length. This is the smaller checked bound and does not bound native AST storage or parser work.
Sourcepub fn with_lexed<R: Send>(
self,
visit: impl FnOnce(LexedSource<'source>) -> R + Send,
) -> Result<R, LoadError>
pub fn with_lexed<R: Send>( self, visit: impl FnOnce(LexedSource<'source>) -> R + Send, ) -> Result<R, LoadError>
Lex on one scoped worker and lend a ticket before syntax parsing starts.
The callback may admit parser resources from the actual token stream,
then consume the ticket. Measurement needs its own prior admission.
Lexing alone does not claim valid syntax or compiler acceptance. The
callback’s typed result is retained unchanged; only its Send value
leaves the joined worker. No source code or Git state is changed.
§Errors
Returns located native lexing, storage or worker-start errors. Syntax errors are returned by the ticket’s consuming parse methods.
§Panics
Resumes parser or callback panics after joining, with the original payload.
Sourcepub fn parse<R: Send>(
self,
visit: impl FnOnce(&File) -> R + Send,
) -> Result<R, LoadError>
pub fn parse<R: Send>( self, visit: impl FnOnce(&File) -> R + Send, ) -> Result<R, LoadError>
Parse the admitted text on its scoped worker, then join it.
§Errors
Returns the native storage, syntax or worker-start errors of parse_source.
§Panics
Resumes parser or visitor panics on the caller with the original payload.
Sourcepub fn parse_with_tokens<R: Send>(
self,
visit: impl FnOnce(&File, TokenStream) -> R + Send,
) -> Result<R, LoadError>
pub fn parse_with_tokens<R: Send>( self, visit: impl FnOnce(&File, TokenStream) -> R + Send, ) -> Result<R, LoadError>
Parse once and lend the original native tokens to the worker visitor.
§Errors
Returns the native errors of parse_source_with_tokens, without rescanning.
§Panics
Resumes parser or visitor panics on the caller with the original payload.
Trait Implementations§
Auto Trait Implementations§
impl<'source> Forget for PreparedSource<'source>
impl<'source> Freeze for PreparedSource<'source>
impl<'source> Move for PreparedSource<'source>
impl<'source> RefUnwindSafe for PreparedSource<'source>
impl<'source> Send for PreparedSource<'source>
impl<'source> Sync for PreparedSource<'source>
impl<'source> Unpin for PreparedSource<'source>
impl<'source> UnsafeUnpin for PreparedSource<'source>
impl<'source> UnwindSafe for PreparedSource<'source>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> EvidenceLease for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more