<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Start</title>
    <description>The latest articles on DEV Community by Start (@lusida2026).</description>
    <link>https://dev.to/lusida2026</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4273384%2Fcb066f9b-d2e4-4498-bc01-2b62e8fdbfb5.png</url>
      <title>DEV Community: Start</title>
      <link>https://dev.to/lusida2026</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lusida2026"/>
    <language>en</language>
    <item>
      <title>Strict Scopes in Rust DI: When a Container Should Refuse to Resolve</title>
      <dc:creator>Start</dc:creator>
      <pubDate>Mon, 30 Nov 2026 05:30:43 +0000</pubDate>
      <link>https://dev.to/lusida2026/strict-scopes-in-rust-di-when-a-container-should-refuse-to-resolve-gon</link>
      <guid>https://dev.to/lusida2026/strict-scopes-in-rust-di-when-a-container-should-refuse-to-resolve-gon</guid>
      <description>&lt;p&gt;Dependency injection in Rust often ends up as a global &lt;code&gt;OnceLock&lt;/code&gt; plus a few &lt;code&gt;Arc&amp;lt;Mutex&amp;lt;...&amp;gt;&amp;gt;&lt;/code&gt; values.&lt;/p&gt;

&lt;p&gt;That is not because the teams do not understand lifetimes.&lt;/p&gt;

&lt;p&gt;It is because the standard library has no container, and the easiest thing that compiles is a singleton.&lt;/p&gt;

&lt;p&gt;The problem with a singleton is not performance. It is that it conflates creation time with ownership.&lt;/p&gt;

&lt;p&gt;A connection pool, a request context, and a cache client do not have the same lifetime.&lt;/p&gt;

&lt;p&gt;When they are all process-wide, the first concurrent bug is usually a &lt;code&gt;DbContext&lt;/code&gt; shared across two requests.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three lifetimes, one rule
&lt;/h2&gt;

&lt;p&gt;rust-dix uses the Microsoft.Extensions.DependencyInjection model: singleton, scoped, transient.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Lifetime&lt;/th&gt;
&lt;th&gt;One instance per&lt;/th&gt;
&lt;th&gt;Typical use&lt;/th&gt;
&lt;th&gt;Common mistake&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Singleton&lt;/td&gt;
&lt;td&gt;process&lt;/td&gt;
&lt;td&gt;config, pool, cache client&lt;/td&gt;
&lt;td&gt;registering &lt;code&gt;DbContext&lt;/code&gt; as singleton&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Scoped&lt;/td&gt;
&lt;td&gt;request or task&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;DbContext&lt;/code&gt;, request context&lt;/td&gt;
&lt;td&gt;resolving it from the root&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Transient&lt;/td&gt;
&lt;td&gt;resolution&lt;/td&gt;
&lt;td&gt;stateless helpers&lt;/td&gt;
&lt;td&gt;giving state to a transient&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The rule that matters is strict scopes: resolving a scoped service from the root provider returns a typed error, &lt;code&gt;ScopedFromRootProvider&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It does not hand you a root-owned instance and hope you remember.&lt;/p&gt;

&lt;h2&gt;
  
  
  Registering is easy; resolving is the design
&lt;/h2&gt;

&lt;p&gt;Registration is a builder call:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="kd"&gt;mut&lt;/span&gt; &lt;span class="n"&gt;services&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ServiceCollection&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;singleton&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Arc&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;AppConfig&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;scoped&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;sp&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;resolve_arc&lt;/span&gt;&lt;span class="o"&gt;::&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;DbContextOptions&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kc"&gt;Ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Arc&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;DbContext&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The factory uses &lt;code&gt;resolve_arc&lt;/code&gt;, not &lt;code&gt;get&lt;/code&gt;. A missing dependency is a typed error at build or resolution time, not a panic and not a silent &lt;code&gt;None&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For a web request, the handler asks for an owned &lt;code&gt;DbContext&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="cp"&gt;#[derive(Inject)]&lt;/span&gt;
&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="nc"&gt;CancelOrderHandler&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="cp"&gt;#[inject(owned)]&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;DbContext&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="cp"&gt;#[inject]&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="n"&gt;clock&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Arc&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;dyn&lt;/span&gt; &lt;span class="nc"&gt;IClock&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a background worker, there is no request scope. The worker injects &lt;code&gt;Arc&amp;lt;dyn ScopeFactory&amp;gt;&lt;/code&gt; and creates one scope per tick:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;scope&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;scopes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create_scope&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="kd"&gt;mut&lt;/span&gt; &lt;span class="n"&gt;ctx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get_owned&lt;/span&gt;&lt;span class="o"&gt;::&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;DbContext&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// one tick of work&lt;/span&gt;
&lt;span class="nb"&gt;drop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// releases scoped services in reverse order&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The important part is not the syntax. It is that the code has to say who owns the context.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it costs
&lt;/h2&gt;

&lt;p&gt;Strictness moves the thinking earlier. That is not free.&lt;/p&gt;

&lt;p&gt;A CLI or a small script does not benefit from a container.&lt;/p&gt;

&lt;p&gt;The lifetime rules become noise, and rust-dix provides a lenient mode for debugging, but it should not reach production.&lt;/p&gt;

&lt;p&gt;Async initialization is another edge. A provider that needs an async connection must go through &lt;code&gt;build_async&lt;/code&gt; or an async factory.&lt;/p&gt;

&lt;p&gt;Calling &lt;code&gt;block_on&lt;/code&gt; inside a synchronous factory tends to hang the startup rather than return a business error.&lt;/p&gt;

&lt;p&gt;There is also a boundary around where the container is built. It belongs in the host composition root, not inside a library crate.&lt;/p&gt;

&lt;p&gt;A library that constructs its own &lt;code&gt;ServiceCollection&lt;/code&gt; reverses the dependency direction and makes tests harder to isolate.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Cost&lt;/th&gt;
&lt;th&gt;What it looks like&lt;/th&gt;
&lt;th&gt;Mitigation&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Earlier design work&lt;/td&gt;
&lt;td&gt;you decide ownership before writing the handler&lt;/td&gt;
&lt;td&gt;map lifetimes to layers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Async initialization&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;block_on&lt;/code&gt; in a sync factory hangs startup&lt;/td&gt;
&lt;td&gt;use &lt;code&gt;build_async&lt;/code&gt; / async factory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Container placement&lt;/td&gt;
&lt;td&gt;a library builds its own collection&lt;/td&gt;
&lt;td&gt;build it in the composition root&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;None of these is a reason to avoid a container. They are reasons to use one only when the lifetime question is real.&lt;/p&gt;

&lt;h2&gt;
  
  
  A five-minute check
&lt;/h2&gt;

&lt;p&gt;If you are cleaning up global singletons, do the smallest experiment.&lt;/p&gt;

&lt;p&gt;Register &lt;code&gt;DbContext&lt;/code&gt; as scoped. Change one handler to &lt;code&gt;#[inject(owned)]&lt;/code&gt;. Then deliberately resolve &lt;code&gt;DbContext&lt;/code&gt; from a singleton.&lt;/p&gt;

&lt;p&gt;If you get &lt;code&gt;ScopedFromRootProvider&lt;/code&gt;, the constraint is doing its job. If you do not, either the registration is wrong or the scope is not the one you think it is.&lt;/p&gt;

&lt;p&gt;That error is more useful than a comment saying "do not share this".&lt;/p&gt;

&lt;p&gt;Repository: &lt;a href="https://github.com/Rust-Framework/rust-dix" rel="noopener noreferrer"&gt;https://github.com/Rust-Framework/rust-dix&lt;/a&gt;&lt;/p&gt;

</description>
      <category>rust</category>
      <category>architecture</category>
      <category>dependencyinjection</category>
      <category>backend</category>
    </item>
    <item>
      <title>An EF Core-Inspired ORM for Rust: Change Tracking, Not Just SQL</title>
      <dc:creator>Start</dc:creator>
      <pubDate>Mon, 30 Nov 2026 05:25:11 +0000</pubDate>
      <link>https://dev.to/lusida2026/an-ef-core-inspired-orm-for-rust-change-tracking-not-just-sql-5fp4</link>
      <guid>https://dev.to/lusida2026/an-ef-core-inspired-orm-for-rust-change-tracking-not-just-sql-5fp4</guid>
      <description>&lt;p&gt;Most Rust ORM discussions start with SQL generation. Can it produce a window function? Does it support &lt;code&gt;LATERAL&lt;/code&gt;? How many queries for this join?&lt;/p&gt;

&lt;p&gt;Those questions matter. They are also not where most business code breaks.&lt;/p&gt;

&lt;p&gt;The code that breaks is usually a partial update that overwrites a concurrent change.&lt;/p&gt;

&lt;p&gt;Or a migration that cannot run on an existing database. Or a transaction that commits half the work.&lt;/p&gt;

&lt;p&gt;None of those failures makes noise in a unit test.&lt;/p&gt;

&lt;p&gt;rust-ef 2.9.1 takes the EF Core model and aims at those problems: a &lt;code&gt;DbContext&lt;/code&gt;, explicit change tracking, transactions, and migrations.&lt;/p&gt;

&lt;h2&gt;
  
  
  The entity owns its schema
&lt;/h2&gt;

&lt;p&gt;An entity and its configuration live together:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="cp"&gt;#[derive(EntityType)]&lt;/span&gt;
&lt;span class="cp"&gt;#[table("orders")]&lt;/span&gt;
&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="nc"&gt;Order&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="cp"&gt;#[primary_key]&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="n"&gt;tenant_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="cp"&gt;#[concurrency_check]&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;i64&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="nc"&gt;OrderConfiguration&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="cp"&gt;#[entity(Order)]&lt;/span&gt;
&lt;span class="k"&gt;impl&lt;/span&gt; &lt;span class="nc"&gt;IEntityTypeConfiguration&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Order&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nc"&gt;OrderConfiguration&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;configure&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="kd"&gt;mut&lt;/span&gt; &lt;span class="nc"&gt;EntityTypeBuilder&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;'_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Order&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;has_index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;Order&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;COLUMN_TENANT_ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Order&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;COLUMN_STATUS&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The point is not the attribute syntax. It is that the schema is declared next to the type that uses it, and the migration tool can read it.&lt;/p&gt;

&lt;p&gt;If the table is created by hand-written SQL, the next environment will drift. That drift is invisible until a query fails in staging.&lt;/p&gt;

&lt;h2&gt;
  
  
  Queries are typed, but writes are tracked
&lt;/h2&gt;

&lt;p&gt;A list query uses a &lt;code&gt;Predicate&lt;/code&gt; and a paginated terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;predicate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Predicate&lt;/span&gt;&lt;span class="o"&gt;::&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Order&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;::&lt;/span&gt;&lt;span class="nf"&gt;always&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="ow"&gt;and&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;linq!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Order&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tenant_id&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;tenant&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;and_opt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;keyword&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nf"&gt;linq!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Order&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;no&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;contains&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set&lt;/span&gt;&lt;span class="o"&gt;::&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Order&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;predicate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;order_by_field_desc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Order&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;created_at&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then_by_field_desc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Order&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to_page&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;paging&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map_items&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;OrderModel&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;from&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A command does not call &lt;code&gt;UPDATE&lt;/code&gt; with every column. It edits the tracked entity, lets the context detect changes, and saves:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;edit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;patch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;detect_changes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;save_changes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;detect_changes&lt;/code&gt; writes only the dirty columns.&lt;/p&gt;

&lt;p&gt;That matters when two people edit the same order: a full-row update overwrites the other person's change even if the fields do not overlap.&lt;/p&gt;

&lt;p&gt;The cost is that you have to load the entity first.&lt;/p&gt;

&lt;p&gt;For a bulk status update over 100,000 rows, that is the wrong tool.&lt;/p&gt;

&lt;p&gt;rust-ef has &lt;code&gt;execute_update&lt;/code&gt; for that case, and it bypasses change tracking and interceptors on purpose.&lt;/p&gt;

&lt;h2&gt;
  
  
  Transactions and error mapping are boundaries
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use_transaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;move&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;save_changes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kc"&gt;Ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The transaction boundary is explicit.&lt;/p&gt;

&lt;p&gt;So is the error boundary.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;EFError&lt;/code&gt; implements &lt;code&gt;From&amp;lt;EFError&amp;gt; for AppError&lt;/code&gt;, so a handler can use &lt;code&gt;?&lt;/code&gt; and let the framework map unique violations, concurrency conflicts, and connection failures.&lt;/p&gt;

&lt;p&gt;There is no &lt;code&gt;rust-webx&lt;/code&gt; feature and no bridge crate. rust-ef does not depend on the web framework.&lt;/p&gt;

&lt;p&gt;That keeps the ORM usable in a worker or a CLI, and it removes a whole class of version coupling.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does not do
&lt;/h2&gt;

&lt;p&gt;This is not EF Core parity, and it does not try to be.&lt;/p&gt;

&lt;p&gt;Complex reporting still needs typed projections (&lt;code&gt;select_items&lt;/code&gt;, &lt;code&gt;to_list_rows&lt;/code&gt;) or the raw SQL escape hatch.&lt;/p&gt;

&lt;p&gt;Migrations still need a plan for SQLite's limited &lt;code&gt;ALTER TABLE&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The persistence adapters for auth, outbox, idempotency, AI usage, and payment inbox live in the framework repository under &lt;code&gt;examples/adapters/*/ef&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;They are &lt;code&gt;publish = false&lt;/code&gt; and meant to be copied, not depended on.&lt;/p&gt;

&lt;p&gt;That last point is easy to miss. If you add &lt;code&gt;rust-webx-pay-ef&lt;/code&gt; to &lt;code&gt;Cargo.toml&lt;/code&gt;, it will not resolve. The table and the adapter belong to your service.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it on one aggregate
&lt;/h2&gt;

&lt;p&gt;Do not migrate the whole schema first.&lt;/p&gt;

&lt;p&gt;Pick one aggregate with a real state transition.&lt;/p&gt;

&lt;p&gt;Write the entity and its configuration. Replace one read with &lt;code&gt;Predicate&lt;/code&gt; + &lt;code&gt;to_page&lt;/code&gt;. Replace one write with &lt;code&gt;edit&lt;/code&gt; + &lt;code&gt;detect_changes&lt;/code&gt; + &lt;code&gt;save_changes&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Then run the migration diff against a copy of the database.&lt;/p&gt;

&lt;p&gt;If the diff is empty on the first try, the model and the schema agree. If it is not, you have found the drift before production did.&lt;/p&gt;

&lt;p&gt;Repository: &lt;a href="https://github.com/Rust-Framework/rust-ef" rel="noopener noreferrer"&gt;https://github.com/Rust-Framework/rust-ef&lt;/a&gt;&lt;/p&gt;

</description>
      <category>rust</category>
      <category>database</category>
      <category>orm</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Request-as-Endpoint: An ASP.NET Core-Shaped API in Rust</title>
      <dc:creator>Start</dc:creator>
      <pubDate>Mon, 30 Nov 2026 05:24:50 +0000</pubDate>
      <link>https://dev.to/lusida2026/request-as-endpoint-an-aspnet-core-shaped-api-in-rust-29ee</link>
      <guid>https://dev.to/lusida2026/request-as-endpoint-an-aspnet-core-shaped-api-in-rust-29ee</guid>
      <description>&lt;p&gt;The first thing you notice when porting an ASP.NET Core service to Rust is not the borrow checker.&lt;/p&gt;

&lt;p&gt;It's that routing, model binding, and error mapping have become three separate decisions.&lt;/p&gt;

&lt;p&gt;You pick a router. You write extractors. You add a response wrapper. You add an error type and a &lt;code&gt;From&lt;/code&gt; impl.&lt;/p&gt;

&lt;p&gt;None of these is hard. The problem is that they drift.&lt;/p&gt;

&lt;p&gt;The route string, the DTO, the validation, and the OpenAPI annotation all describe the same operation, in four places.&lt;/p&gt;

&lt;p&gt;rust-webx 2.9.4 takes the ASP.NET Core bet: define the request first, and let the framework attach the rest.&lt;/p&gt;

&lt;h2&gt;
  
  
  One request type is the endpoint
&lt;/h2&gt;

&lt;p&gt;A minimal endpoint looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="cp"&gt;#[derive(WebxRequestMeta)]&lt;/span&gt;
&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="nc"&gt;GetOrderRequest&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="cp"&gt;#[fromclaim]&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;IdentityUser&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="cp"&gt;#[frompath]&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cp"&gt;#[get("/api/orders/{id}")]&lt;/span&gt;
&lt;span class="cp"&gt;#[authorize(dynamic, permission = "tenant.order.read")]&lt;/span&gt;
&lt;span class="k"&gt;impl&lt;/span&gt; &lt;span class="nc"&gt;IRequest&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;OrderModel&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nc"&gt;GetOrderRequest&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cp"&gt;#[handler(inject)]&lt;/span&gt;
&lt;span class="cp"&gt;#[async_trait]&lt;/span&gt;
&lt;span class="k"&gt;impl&lt;/span&gt; &lt;span class="nc"&gt;IRequestHandler&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;GetOrderRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;OrderModel&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nc"&gt;GetOrderHandler&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;handle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="kd"&gt;mut&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;GetOrderRequest&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;ActionResult&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;OrderModel&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;load_order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="kd"&gt;mut&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The route macro sits on &lt;code&gt;impl IRequest&amp;lt;T&amp;gt;&lt;/code&gt;, not on the struct and not on the handler.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;#[derive(WebxRequestMeta)]&lt;/code&gt; describes where each field comes from. &lt;code&gt;#[fromclaim]&lt;/code&gt; means "take it from the authenticated request", not "parse it from JSON".&lt;/p&gt;

&lt;p&gt;At compile time, route metadata and handler registrations are collected through &lt;code&gt;inventory&lt;/code&gt;. &lt;code&gt;Host::build()&lt;/code&gt; joins them.&lt;/p&gt;

&lt;p&gt;If a request type has no handler, the host fails to start.&lt;/p&gt;

&lt;p&gt;That is the trade: you cannot ship an endpoint that is half-wired.&lt;/p&gt;

&lt;p&gt;The cost is that a missing handler shows up during startup rather than during code review.&lt;/p&gt;

&lt;h2&gt;
  
  
  Binding is part of the contract
&lt;/h2&gt;

&lt;p&gt;Pagination is a good example because every service has it and every service gets it subtly wrong.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="cp"&gt;#[derive(WebxRequestMeta)]&lt;/span&gt;
&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="nc"&gt;ListOrdersRequest&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="cp"&gt;#[fromclaim]&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;IdentityUser&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="cp"&gt;#[fromquery]&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="n"&gt;keyword&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Option&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="cp"&gt;#[fromquery(nested)]&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="n"&gt;paging&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;PagedRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cp"&gt;#[get("/api/orders")]&lt;/span&gt;
&lt;span class="k"&gt;impl&lt;/span&gt; &lt;span class="nc"&gt;IRequest&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;PagedResult&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;OrderModel&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nc"&gt;ListOrdersRequest&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;PagedRequest&lt;/code&gt; has &lt;code&gt;page&lt;/code&gt; and &lt;code&gt;page_size&lt;/code&gt;, defaults to 1/20, and returns a 400 with a field path when values are out of range.&lt;/p&gt;

&lt;p&gt;The handler does not clamp them again.&lt;/p&gt;

&lt;p&gt;The response is a flat &lt;code&gt;PagedResult&amp;lt;T&amp;gt;&lt;/code&gt; (&lt;code&gt;items&lt;/code&gt;, &lt;code&gt;total&lt;/code&gt;, plus &lt;code&gt;success/status/message&lt;/code&gt;), not a nested page envelope.&lt;/p&gt;

&lt;p&gt;The part that matters for a team is not the field names.&lt;/p&gt;

&lt;p&gt;It is that the binding rules live with the request type, so a new endpoint gets the same behavior without copying a helper.&lt;/p&gt;

&lt;h2&gt;
  
  
  Errors have one carrier
&lt;/h2&gt;

&lt;p&gt;Handlers return &lt;code&gt;ActionResult&amp;lt;T&amp;gt;&lt;/code&gt;, which is &lt;code&gt;Result&amp;lt;T, AppError&amp;gt;&lt;/code&gt;. Database errors, DI errors, and cursor errors each implement &lt;code&gt;From&lt;/code&gt; at their own boundary.&lt;/p&gt;

&lt;p&gt;So the handler can use &lt;code&gt;?&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;order&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set&lt;/span&gt;&lt;span class="o"&gt;::&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Order&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;linq!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Order&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;first_or_default&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ok_or_else&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;not_found&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"order not found"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Error::not_found&lt;/code&gt; maps to 404. &lt;code&gt;Error::validation&lt;/code&gt; maps to 400.&lt;/p&gt;

&lt;p&gt;For 5xx, the operator text stays in the log and the client only sees &lt;code&gt;public_detail()&lt;/code&gt;, which is empty for internal errors.&lt;/p&gt;

&lt;p&gt;That contract lives in &lt;code&gt;rust-core&lt;/code&gt;, a dependency-light crate shared by rust-webx, rust-ef, and rust-dix.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;webx::Error&lt;/code&gt; is a re-export, not a second definition. In practice this removes the &lt;code&gt;map_*_error&lt;/code&gt; functions that tend to appear in every layered Rust service.&lt;/p&gt;

&lt;h2&gt;
  
  
  The cost is not zero
&lt;/h2&gt;

&lt;p&gt;Request-as-endpoint is a convention, and conventions cost something.&lt;/p&gt;

&lt;p&gt;Every operation needs a request type. For a one-line webhook or a health probe, that feels heavy.&lt;/p&gt;

&lt;p&gt;The framework is opinionated about where routes live. If you prefer function-based routing, this will fight you.&lt;/p&gt;

&lt;p&gt;Startup validation means assembly errors surface at boot. That is good for correctness and annoying for quick scripts.&lt;/p&gt;

&lt;p&gt;The ecosystem is optional, not bundled. WebSocket, payments, and the AI gateway are separate crates.&lt;/p&gt;

&lt;p&gt;Realtime state is in-process by default. Multi-instance deployments need shared stores and a transport that supports broadcast.&lt;/p&gt;

&lt;p&gt;None of this is hidden.&lt;/p&gt;

&lt;p&gt;The framework's own documentation lists the boundaries, including at-most-once broadcast and Kafka's lack of broadcast support.&lt;/p&gt;

&lt;h2&gt;
  
  
  Run the examples
&lt;/h2&gt;

&lt;p&gt;The repository ships three reference apps: &lt;code&gt;docbit&lt;/code&gt; (full-stack with docs and RBAC), &lt;code&gt;dmbit&lt;/code&gt; (device/inventory), and &lt;code&gt;imbit&lt;/code&gt; (realtime IM with HTTP + WebSocket):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cargo run --manifest-path examples/docbit/Cargo.toml -p docbit-host
cargo run --manifest-path examples/imbit/Cargo.toml -p imbit-host
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;imbit&lt;/code&gt; listens on port 8090 by default.&lt;/p&gt;

&lt;p&gt;Its host tests cover messaging, signaling, recording, browser cookie sessions, logout-driven disconnects, and WebSocket origins.&lt;/p&gt;

&lt;p&gt;If you are evaluating the framework, do not start with a benchmark. Start with one existing endpoint.&lt;/p&gt;

&lt;p&gt;Rewrite it as a request type plus a handler, then run &lt;code&gt;Host::builder().try_build()&lt;/code&gt;. The assembly errors you see in the first ten minutes tell you more than a throughput number.&lt;/p&gt;

&lt;p&gt;Repository: &lt;a href="https://github.com/Rust-Framework/rust-webx" rel="noopener noreferrer"&gt;https://github.com/Rust-Framework/rust-webx&lt;/a&gt;&lt;br&gt;
Book: &lt;a href="https://rust-framework.github.io/rust-webx/" rel="noopener noreferrer"&gt;https://rust-framework.github.io/rust-webx/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>rust</category>
      <category>webdev</category>
      <category>architecture</category>
      <category>api</category>
    </item>
  </channel>
</rss>
