Expand description
Laravel-style top-level helpers. Sits above larust-core/larust-http
rather than below them - this is the “batteries-included facade” layer,
analogous to Laravel’s helpers.php. Collection<T> lands later.
Re-exports§
pub use axum;pub use tracing;pub use serde_json;
Modules§
- auth
- cache
- config_
env - Runtime
env/env_bool/env_orhelpers for generatedconfig/*.rsmodules (seelarust_convert::config::convert_body) - the runtime half of every Laravelenv('VAR')/env('VAR', default)call a config file’s own generatedpub fn config() -> serde_json::Valuereferences. Kept inlarust-support(notlarust-core) for the same “app-facing helper, not framework internals” reasonconfig_helper:: configlives here - this is a distinct, narrower mechanism from that one:config_helper::configresolves a fixed, hand-curated set ofConfig-struct-backed keys; this module is the raw env-var read a generated config file’s own arbitrary keys fall back to. - console
- date
- PHP/Laravel-style
date()formatting - not a general date-parsing or date-arithmetic library, just enough to format an already-knownchrono::DateTime<Utc>using PHP’s own format-character vocabulary (Y,m,d,F,j,S, …), so a converted Bladedate('Y-m-d')call reads the same as the Laravel source it came from. - event
- lang
- Not feature-gated - see
spa’s own doc comment for the same reasoning:__()/trans()are core Laravel functionality, not a stand-in for a specific optional third-party package the waypermission/sanctum/etc. are.larust_http::locale::negotiate(the session-reading half of this) lives with the other opt-in HTTP middleware instead of being re-exported here, matchingcsrf::verify/require_auth’s own precedent of being attached via.middleware(...)directly rather than through the facade. - notification
- orm
- preferences
- Backs
@globals’persistentries - seelarust_http::preferences’ own doc comment for the full design (a dedicated, unsigned, long-lived cookie, deliberately notSession-backed). - push
- push_
registry - Runtime home for
@push/@stackcontent that needs to cross a boundary compile-timeview!(...)resolution can’t see across (a<wire:...>mount, or twoview!(...)calls glued by.into_html()) - seelarust_view::push_registry’s own doc comment for the full design. Reached by generated codegen the same waylarust_support::wire::mount/larust_support::view::escapealready are. - queue
- regex_
replace preg_replace($pattern, $replacement, $subject)support - the target oflarust-convert’s Blade expression translator (larust_convert:: blade::expr::translate’s"preg_replace"arm). That translator only ever emits a call here after already compiling the same pattern literal with this exactregexcrate at convert time (its own self-check, mirroringsyn::parse_str::<syn::Expr>’s role everywhere else in that translator) - soreplace_all’s pattern argument is never expected to fail to compile for converter-generated call sites. It still doesn’t panic on one that does (a hand-written call, or a pattern edited after conversion): falling back to returningsubjectunchanged is the same “never fail, best-effort” choicelarust_support::date::strtotimealready makes, for the same reason - this is a runtime helper, not the converter’s own convert-time rejection path.- repository
- The non-SQL half of Larust’s persistence story - see
larust_repository::Repository’s own doc comment for the full design (storage-agnostic CRUD, implemented automatically for#[derive(Model)]structs viaorm::AnyRepository<T>, by hand for anything else). - schedule
- spa
- Not feature-gated, unlike [
permission]/reverb/sanctum/sitemap/socialiteabove -@spais core template-directive surface (the same tier aswire/push), not a stand-in for an optional third-party Laravel package an app opts into compiling. - storage
- strings
- PHP string helpers with no direct Rust standard-library equivalent -
str::trim/str::lenalready cover PHP’strim()/count()on a string, so those translate directly at convert time (larust_convert::blade::expr) without needing anything here. This module exists for the ones that genuinely don’t have a stdlib match. - truthy
- PHP’s implicit “truthy” check (
if ($x),$x ? ... : ...) -false,0,0.0,"","0", an empty array, andnullare falsy; everything else is truthy. Rust’sif/ternary requires a genuinebooland has no equivalent notion, solarust-convert’s Blade expression translator wraps every@if/@elseif/ternary condition intruthyuniformly (larust_convert::blade::expr::translate, the"conditional_expression"arm andblade::scan’s"if"/"elseif"handling) rather than trying to prove at convert time whether a given condition is already a genuinebool- a real boolean-producing expression ($x == $y,$post->is_published) just passes straight through unchanged (Truthy for boolis the identity), so this is never a behavior change for the already-safe cases, only an enabler for the ones that weren’t. - validation
- view
- vitex
- Larust’s own answer to Laravel’s
@vite(...)directive - real integration with the app’s existing Vite/Tailwind toolchain (thelaravel-vite-plugin-basedvite.config.js/tailwind.config.js/package.jsona converted app’s ownresources/assets/already carries over), not a from-scratch asset bundler.xr converttranslates every real@vite([...])call it finds into a@code/{!! !!}pair callingtagswith the exact same entry-point strings - seelarust_convert::blade::scan’s own"vite"directive arm. - wire
Macros§
- error_
view #[derive(FormRequest)],view!,error_view!, and#[derive(Model)]- re-exported here so generated apps depend only onlarust-support, not onlarust-macrosdirectly. All four macros’ generated code assumes this re-export path (::larust_support::...).error_view!("404"): compilesresources/views/errors/404.blade.xrif the app defines one, else Larust’s own built-in default page for that status - always produces aString. Seeerror_view.rs’s own doc comment for the override mechanism’s limitations (no context bindings, so no@wire/@can/@role/persistglobals, and best kept self-contained rather than@extends-ing a session-aware layout).- view
#[derive(FormRequest)],view!,error_view!, and#[derive(Model)]- re-exported here so generated apps depend only onlarust-support, not onlarust-macrosdirectly. All four macros’ generated code assumes this re-export path (::larust_support::...).view!("posts.index", { posts }): reads, parses, and resolvesresources/views/posts/index.blade.xr(including any@extendslayout chain) at compile time, and generates code that renders it into aView. Interpolated expressions ({{ user.name }}) and directive conditions/iterables (@if(...),@foreach(...)) are parsed as real Rust expressions and spliced directly into the generated function body - an undeclared variable is a genuinerustccompile error, not a custom check.
Structs§
- Loop
- One iteration’s position, alongside the item itself - see
WithLoop. - Redirect
- Redirect
Builder
Enums§
- AppError
- Re-exported (not just used internally) so macro-generated code can
reference
::larust_support::axum::.../::larust_support::AppErrorinstead of::larust_core::...- a crate depending onlarust-supportalone must not needlarust-coreas a direct dependency just to use a macro. Keep every path inlarust-macros’ generated code routed throughlarust_supportfor the same reason.default_not_found_html/default_internal_htmlareerror_view!’s own fallback when noresources/views/errors/{code}.blade.xroverride exists. The framework’s primary error type.
Traits§
- With
Loop .with_loop()- wraps any iterator whose length is known up front (ExactSizeIterator, satisfied by.iter()on aVec/slice/HashMap,.iter().enumerate()over one of those, and more) into one yielding(item, Loop)pairs.
Functions§
- abort
- Laravel’s
abort(status): builds anAppErrorfor a specific HTTP status, to be returned (typically via?) from a controller. - asset
- Laravel’s
asset($path)only differs fromurl($path)once a separate CDN/ASSET_URLis configured - no such concept exists in this framework yet, so this is a direct delegation, matching Laravel’s own default behavior when no separate asset URL is set. A real, distinct implementation (and its own config field) is a natural addition if a CDN-hosted-assets need ever shows up. - config
- Laravel-shaped
config('app.name')string lookup - a deliberate, isolated exception to this framework’s usual compile-checked config access (app.config().app_name, still available and still preferred for anything statically known); kept narrow (one match arm per known key) rather than a general dynamic-config system. - default_
internal_ html - Re-exported (not just used internally) so macro-generated code can
reference
::larust_support::axum::.../::larust_support::AppErrorinstead of::larust_core::...- a crate depending onlarust-supportalone must not needlarust-coreas a direct dependency just to use a macro. Keep every path inlarust-macros’ generated code routed throughlarust_supportfor the same reason.default_not_found_html/default_internal_htmlareerror_view!’s own fallback when noresources/views/errors/{code}.blade.xroverride exists. The framework’s own built-in 500 page. Production-mode only - debug mode (APP_DEBUG=true) never reaches this; seeerror::debug_page. - default_
not_ found_ html - Re-exported (not just used internally) so macro-generated code can
reference
::larust_support::axum::.../::larust_support::AppErrorinstead of::larust_core::...- a crate depending onlarust-supportalone must not needlarust-coreas a direct dependency just to use a macro. Keep every path inlarust-macros’ generated code routed throughlarust_supportfor the same reason.default_not_found_html/default_internal_htmlareerror_view!’s own fallback when noresources/views/errors/{code}.blade.xroverride exists. The framework’s own built-in 404 page - styled to match the demo app’s branding (seepage_shell’s own doc comment for the exact source of the color tokens/copy this mirrors). - redirect
- Entry point for Laravel’s
redirect()helper. - route
- Resolves a named route to its declared path (Laravel’s
route($name)). Fails if no route with that name was registered, or if the resolved path still has an unsubstituted{param}placeholder - this function takes no parameters, so a route that needs one (/posts/{post}) must be resolved viaroute_withinstead; erroring here (rather than returning the literal, broken/posts/{post}string) is what steers a caller toward the right function instead of shipping a dead link. - route_
with - Resolves a named route, substituting each
{key}placeholder in its declared path with the matching value fromparams(Laravel’sroute($name, $params), minus the array/positional-value flexibility -paramsis explicit(name, value)pairs here, matching this codebase’s existing “explicit, never inferred” stance for anything with this shape, e.g.#[belongs_to_many(...)]’srelated_pivot_keyorRoute::resource’sparamargument). - sanitize_
rich_ text - Sanitizes user-authored HTML (e.g. a rich-text editor’s output) down to
a safe subset before it’s persisted or rendered - strips
<script>/event-handler attributes/javascript:URLs, keeps ordinary formatting markup (paragraphs, headings, lists, links, images, etc.). Ammonia’s default tag/attribute allowlist matches typical rich-text editor output (Trix, and similarcontenteditable-based editors) closely enough to need no custom configuration for this. - url
- Builds an absolute URL from
path, using the app’s configuredAPP_URL(Laravel’surl($path)).
Derive Macros§
- Form
Request #[derive(FormRequest)],view!,error_view!, and#[derive(Model)]- re-exported here so generated apps depend only onlarust-support, not onlarust-macrosdirectly. All four macros’ generated code assumes this re-export path (::larust_support::...).#[derive(FormRequest)]: generates anaxum::extract::FromRequestimpl that validates a form-urlencoded body against each field’s#[validate(...)]rules before the handler runs, returning a 422 with Laravel-shaped field errors on failure (Laravel’sFormRequest).- Model
#[derive(FormRequest)],view!,error_view!, and#[derive(Model)]- re-exported here so generated apps depend only onlarust-support, not onlarust-macrosdirectly. All four macros’ generated code assumes this re-export path (::larust_support::...).#[derive(Model)]: generatesTABLE/field-name constants,query(),all(),find(id),create(data), anddelete(id)overlarust-orm’sQueryBuilder, plus route model binding - anaxum::extract::FromRequestPartsimpl so a handler can declarepost: Poston a route like/posts/{post}and have it auto-resolved (404 if not found). Requires#[table("...")]on the struct and exactly one#[primary_key]field (currently must bei64).#[route_key("slug")]looks records up by that field instead of the primary key.#[timestamps](Laravel’s$table->timestamps()) opts into automaticcreated_at/updated_atpopulation - both must exist asi64(Unix seconds) fields;create()stamps both,update()re-stampsupdated_atonly, and neither appears in the generatedNew*struct, matching Eloquent’s own “never set these yourself” behavior.