One static lookup without an array driver in Laravel Rust
Scope
Replace one read-only Sushi model backed by a small, trusted, release-owned row set with an explicit lookup. Preserve codes, labels, ordering and the existing response shape. Exclude dynamic getRows, remote/user/tenant data, mutable rows, general SQL, relationship emulation and validation rules referring to a model connection. Keep those callers on their original path. Preserve the upstream MIT notice when adapting source.
At the time of writing, the Package Port catalog listed Rust and Go gaps. Check get-recipe's current port catalog before choosing to inline. A small typed list may solve this caller without recreating an array database. This guidance has not been exercised in your app; verify it with the checks below.
Source behaviour
src/Sushi.php turns getRows() into a SQLite table. It derives columns from the first row with optional schema overrides, may add an incrementing key, and inserts rows in chunks. A numeric-looking string can be inferred as a float unless the model declares a schema. The original model's schema/casts therefore matter to code identity and output.
Caching defaults to models with a rows property; cache freshness compares the reference file's modification time to the SQLite cache file. Other paths can use in-memory SQLite. This is not a guarantee of durable writes or arbitrary external-source freshness. tests/SushiTest.php exercises schema, empty data, cache selection and relationships; its same-cache-between-requests test is skipped, so do not cite it as proof of cross-worker cache consistency.
Implementation
- Inventory actual row source, schema/casts, generated IDs, default ordering, model accessors, scopes, relationship/validation references and all readers/writers. Select only an immutable bounded list shipped with the app. If row identity is a generated integer used elsewhere, preserve that mapping explicitly rather than deriving it from new list positions.
- Define typed code/label rows beside their owning feature. Validate the complete list once before serving: required fields, unique exact codes, string types and permitted size. Preserve leading zeros and declared order. Do not silently choose the first duplicate or replace unknown codes with the first row. The lookup below assumes this validation already succeeded.
- Replace only the selected exact-code lookup, returning an optional result and mapping it to the endpoint's existing not-found contract. A byte-exact string comparison deliberately differs from SQLite coercion/collation where the original query allowed it; compare real fixtures and either preserve that behavior explicitly or record the change. Do not claim every Eloquent query has been replaced.
- Keep authorization and tenant checks at the existing boundary. Only truly public, tenant-independent rows may live in shared immutable data. Do not cache authenticated response objects or load external files/URLs selected by input. Match resource projection and escape labels for the output context.
- No database, filesystem cache, transaction or migration is needed for this static subset. Deploy the data and code together and recycle long-lived workers so they see the new release. If updates must happen independently of releases, this static approach is the wrong boundary; retain or separately design its existing persistence/cache invalidation. Leave old SQLite files and any durable data alone during the initial cutover.
Complete pure lookup for a previously validated list of exact string codes and non-null labels. The caller owns data loading, uniqueness, permissions and response mapping:
fn zone_label<'a>(zones: &[(&str, &'a str)], code: &str) -> Option<&'a str> {
zones.iter().find_map(|(key, label)| (*key == code).then_some(*label))
}
Acceptance checklist
- For rows
("01", "North"),("1", "South"),("10", ""), assert exact distinct labels for01and1, a present empty label for10, and no value for001, an absent code or an empty list. Do not coerce codes to numbers. - Reject duplicate codes, non-string fields and oversized lists at initialization. Preserve Unicode labels and explicit ordering. Test any old schema/collation difference against the source-backed caller and record deliberate changes.
- Keep every externally referenced old ID stable. Verify resource shape, missing-value error/status, accessors, and selected call sites; retain excluded relationships/validation rules and other queries.
- Unauthorized requests and tenant-specific values cannot leak through shared lists/caches. A second worker sees a new release's rows after rollout without modifying another request's data.
- The selected read writes no SQLite file and makes no database/network call. Confirm no hidden dynamic
getRowsbehavior or writes were relied on before removing the package.
Run formatting, strict Clippy, lookup/resource/authorization tests and a release-refresh check in the destination app. Record versions, outputs and intentional differences with the change. Pure lookup tests do not establish Eloquent query parity.
Sources
- MIT reference source:
src/Sushi.phpandtests/SushiTest.php. PreserveLICENSE.md. - Framework source checked:
crates/http/src/http/json.rs; use the app's existing response boundary and reconcile metadata with its lockfile. This pure lookup needs no framework database API. - Port options: check
get-recipe's current port catalog (sourced from Package Port) at implementation time.