Skip to main content

ConvertContext

Struct ConvertContext 

Source
pub struct ConvertContext<'a> {
    pub laravel_root: &'a Path,
    pub resolved_config_keys: &'a HashSet<String>,
    pub tainted_vars: RefCell<HashSet<String>>,
    pub degraded_spot_count: Cell<usize>,
}
Expand description

Convert-time context threaded through every Blade-conversion call - scan.rs’s own directive/tag scanning and, through it, expr.rs’s expression translation. Lives here, one level up from both, rather than in either - scan already depends on expr (use super::expr;), so defining this type in scan and having expr reference it back would make the two modules mutually dependent for no reason beyond avoiding one extra use at this shared level.

Fields§

§laravel_root: &'a Path

Only ever read by scan::scan_livewire_tag, to resolve a nested <livewire:X> component’s own PHP class and enrich its translation with whatever default property values it declares.

§resolved_config_keys: &'a HashSet<String>

Every "{config file stem}.{key}" pair a generated config/{file}.rs module successfully resolved (see larust_convert::config::convert_body) - expr.rs’s "config" function-call arm checks membership here to decide whether config('file.key') has a real generated home to reference, never touching the underlying value itself (that already lives in the generated file by the time this runs).

§tainted_vars: RefCell<HashSet<String>>

Variable names a dropped top-level @php block would have assigned (see scan.rs’s own doc comment for the full mechanism) - expr::translate’s "variable_name" arm treats a reference to any name in here as unsupported, the same as an undefined superglobal, so it degrades in place instead of translating into a reference to a binding that no longer exists. Mutated inline during a single left-to-right scan (never re-read from an earlier position - Blade renders top-to-bottom and PHP has no forward declarations, so a reference can only follow the assignment that taints it), hence the interior mutability despite ConvertContext otherwise being pure borrowed, read-only config.

Must be constructed fresh per file, never reused across a whole conversion run - taint from one file’s own @php block has no meaning for the next file’s variables of the same name.

§degraded_spot_count: Cell<usize>

How many spots in the current file have degraded so far - every degrade site calls scan::next_degraded_spot(ctx) to claim the next number, embedded in both the inline placeholder (<!-- ... (spot #N) ... -->, always safe to embed - a bare integer, never raw source) and the matching CONVERSION_REPORT.md note (which also carries the real original source text, safe there because a Markdown report is never re-parsed as a template the way a .blade.xr file is). Lets a file with several drops actually be navigated - a spot in the output can be traced to its exact report entry instead of a pile of identical, anonymous placeholder comments. Must be constructed fresh per file, same reasoning as tainted_vars.

Auto Trait Implementations§

§

impl<'a> !Freeze for ConvertContext<'a>

§

impl<'a> !RefUnwindSafe for ConvertContext<'a>

§

impl<'a> !Sync for ConvertContext<'a>

§

impl<'a> Forget for ConvertContext<'a>

§

impl<'a> Move for ConvertContext<'a>

§

impl<'a> Send for ConvertContext<'a>

§

impl<'a> Unpin for ConvertContext<'a>

§

impl<'a> UnsafeUnpin for ConvertContext<'a>

§

impl<'a> UnwindSafe for ConvertContext<'a>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more