Skip to main content

PreparedSource

Struct PreparedSource 

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

Source

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.

Source

pub const fn recursion(&self) -> usize

The highest additive recursion counter reached by the guard scan.

Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl<'source> Debug for PreparedSource<'source>

Source§

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

Formats the value using the given formatter. Read more

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> 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> EvidenceLease for T
where T: Debug + Send + Sync,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.