Skip to content

feat: rust dx improvements#1324

Closed
guibeira wants to merge 3 commits intomainfrom
rust-dx-improvements
Closed

feat: rust dx improvements#1324
guibeira wants to merge 3 commits intomainfrom
rust-dx-improvements

Conversation

@guibeira
Copy link
Contributor

@guibeira guibeira commented Mar 18, 2026

Summary by CodeRabbit

  • New Features

    • Introduced fluent builder constructors for function registration messages, enabling more concise and readable initialization with chainable method syntax.
  • Documentation

    • Updated all code examples and guides throughout the platform to demonstrate the simplified function registration approach.

@vercel
Copy link
Contributor

vercel bot commented Mar 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
iii-website Ready Ready Preview, Comment Mar 18, 2026 1:19am
motia-docs Ready Ready Preview, Comment Mar 18, 2026 1:19am

Request Review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 18, 2026

📝 Walkthrough

Walkthrough

Adds fluent builder methods (with_id and with_description) to RegisterFunctionMessage in the Rust SDK and updates all documentation examples and test files to replace verbose struct literal initialization with the new constructor-based API.

Changes

Cohort / File(s) Summary
SDK Implementation
sdk/packages/rust/iii/src/protocol.rs
Added two builder methods: with_id(name: String) -> Self and with_description(mut self, description: String) -> Self enabling fluent construction pattern for RegisterFunctionMessage.
Documentation Examples
docs/advanced/telemetry.mdx, docs/api-reference/sdk-rust.mdx, docs/architecture/channels.mdx, docs/architecture/trigger-types.mdx, docs/examples/*, docs/how-to/*, docs/modules/*
Replaced verbose struct literal construction (RegisterFunctionMessage { id: "...", description: None, ... }) with builder-style calls (RegisterFunctionMessage::with_id("...").with_description(...)) across 20+ documentation files.
Test Files
sdk/packages/rust/iii/tests/api_triggers.rs, sdk/packages/rust/iii/tests/bridge.rs, sdk/packages/rust/iii/tests/data_channels.rs, sdk/packages/rust/iii/tests/healthcheck.rs, sdk/packages/rust/iii/tests/http_external_functions.rs, sdk/packages/rust/iii/tests/init_api.rs, sdk/packages/rust/iii/tests/pubsub.rs, sdk/packages/rust/iii/tests/queue_integration.rs, sdk/packages/rust/iii/tests/state.rs
Updated 9 test files to use RegisterFunctionMessage::with_id(...) instead of struct literal initialization for RegisterFunctionMessage construction.
README Files
README.md, engine/README.md, sdk/README.md
Updated three README examples to use the new with_id constructor method instead of struct literals.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

Suggested reviewers

  • ytallo
  • sergiofilhowz

Poem

🐰 A fluent builder blooms, so clean and bright,
No more struct fields cluttering the sight!
with_id chains gently, description flows,
Through docs and tests the pattern grows. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'feat: rust dx improvements' is generic and vague; it mentions 'dx improvements' but does not clearly convey the specific main change (introducing fluent builder methods with_id and with_description for RegisterFunctionMessage). Consider a more specific title that highlights the key change, such as 'feat: add fluent builder methods to RegisterFunctionMessage' or 'feat: simplify RegisterFunctionMessage construction with builder pattern'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 94.29% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch rust-dx-improvements
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
docs/how-to/use-functions-and-triggers.mdx (2)

249-258: ⚠️ Potential issue | 🟡 Minor

Align these result examples with the earlier math::add payload.

The first math::add example in this page returns { id, result }, but these later Rust snippets still imply the response is only { "result": ... }. Please make the output comments/examples match the actual payload shape users will get back.

Also applies to: 669-679

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/how-to/use-functions-and-triggers.mdx` around lines 249 - 258, The
example response comments for the Rust trigger examples are inconsistent with
the earlier math::add payload shape — update the inline output comments and any
printed example values in the math::calculate and related snippets (look for
iii.register_function, math::calculate, iii.trigger, TriggerRequest and
function_id "math::add") to show the full payload shape { "id": <id>, "result":
5 } (or the exact id field used earlier) instead of just { "result": 5 }; also
apply the same correction to the other occurrences noted around the later
snippet range (the second block referenced at lines ~669-679) so all examples
show the { id, result } structure consistently.

165-187: ⚠️ Potential issue | 🟠 Major

Import serde_json::json in the http_invoked.rs snippet.

Line 187 uses the json! macro but the imports do not include serde_json::json, preventing the example from compiling.

🔧 Proposed fix
 use iii_sdk::{register_worker, InitOptions, HttpAuthConfig, HttpInvocationConfig, HttpMethod, RegisterFunctionMessage, TriggerRequest};
+use serde_json::json;
 use std::collections::HashMap;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/how-to/use-functions-and-triggers.mdx` around lines 165 - 187, The
example uses the json! macro but doesn't import it; add the serde_json::json
import to the top imports in the http_invoked.rs snippet so the macro is
available (update the import list alongside iii_sdk::{...}); ensure the
TriggerRequest call that uses json!({ ... }) compiles after adding
serde_json::json.
docs/how-to/expose-http-endpoint.mdx (1)

82-89: ⚠️ Potential issue | 🟠 Major

Remove the ? from register_worker(...) on line 85.

The function signature returns III directly, not a Result. All API reference examples and the SDK docstring use register_worker(...) without the ? operator. This code will not compile as written.

🔧 Proposed fix
-    let iii = register_worker(&url, InitOptions::default())?;
+    let iii = register_worker(&url, InitOptions::default());
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/how-to/expose-http-endpoint.mdx` around lines 82 - 89, The call to
register_worker(...) is incorrectly treated as returning a Result; remove the
`?` operator so the returned III value is assigned directly (e.g., let iii =
register_worker(&url, InitOptions::default());). Update the assignment in main
(the async fn main -> Result<(), Box<dyn std::error::Error>>) to use the direct
III value from register_worker and ensure any subsequent error handling remains
correct for functions that do return Results; target the register_worker(...)
call site and the let iii binding when making this change.
docs/api-reference/sdk-rust.mdx (1)

77-89: ⚠️ Potential issue | 🟡 Minor

Update the generated API reference to document the with_id and with_description builder methods.

The example at line 84 correctly uses RegisterFunctionMessage::with_id(), but these public builder methods are not documented in the RegisterFunctionMessage section below. Since this file is auto-generated, the fix likely requires updating the generator or source annotations so the canonical API reference includes these methods.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/api-reference/sdk-rust.mdx` around lines 77 - 89, The generated API
reference is missing documentation for the public builder methods on
RegisterFunctionMessage (specifically RegisterFunctionMessage::with_id and
RegisterFunctionMessage::with_description); update the source or generator so
these methods are included: add proper Rust doc comments (/// ...) to the
with_id and with_description impls on RegisterFunctionMessage (or adjust the
doc-generator configuration to include inherent impl methods), then regenerate
the API reference so the RegisterFunctionMessage section shows these builder
methods and their signatures/remarks consistent with the example using
RegisterFunctionMessage::with_id().
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@docs/api-reference/sdk-rust.mdx`:
- Around line 77-89: The generated API reference is missing documentation for
the public builder methods on RegisterFunctionMessage (specifically
RegisterFunctionMessage::with_id and RegisterFunctionMessage::with_description);
update the source or generator so these methods are included: add proper Rust
doc comments (/// ...) to the with_id and with_description impls on
RegisterFunctionMessage (or adjust the doc-generator configuration to include
inherent impl methods), then regenerate the API reference so the
RegisterFunctionMessage section shows these builder methods and their
signatures/remarks consistent with the example using
RegisterFunctionMessage::with_id().

In `@docs/how-to/expose-http-endpoint.mdx`:
- Around line 82-89: The call to register_worker(...) is incorrectly treated as
returning a Result; remove the `?` operator so the returned III value is
assigned directly (e.g., let iii = register_worker(&url,
InitOptions::default());). Update the assignment in main (the async fn main ->
Result<(), Box<dyn std::error::Error>>) to use the direct III value from
register_worker and ensure any subsequent error handling remains correct for
functions that do return Results; target the register_worker(...) call site and
the let iii binding when making this change.

In `@docs/how-to/use-functions-and-triggers.mdx`:
- Around line 249-258: The example response comments for the Rust trigger
examples are inconsistent with the earlier math::add payload shape — update the
inline output comments and any printed example values in the math::calculate and
related snippets (look for iii.register_function, math::calculate, iii.trigger,
TriggerRequest and function_id "math::add") to show the full payload shape {
"id": <id>, "result": 5 } (or the exact id field used earlier) instead of just {
"result": 5 }; also apply the same correction to the other occurrences noted
around the later snippet range (the second block referenced at lines ~669-679)
so all examples show the { id, result } structure consistently.
- Around line 165-187: The example uses the json! macro but doesn't import it;
add the serde_json::json import to the top imports in the http_invoked.rs
snippet so the macro is available (update the import list alongside
iii_sdk::{...}); ensure the TriggerRequest call that uses json!({ ... })
compiles after adding serde_json::json.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6c5bca45-f89c-4e52-a80f-67f74e38e7b0

📥 Commits

Reviewing files that changed from the base of the PR and between 87777f4 and 2e8fd85.

📒 Files selected for processing (39)
  • README.md
  • docs/advanced/telemetry.mdx
  • docs/api-reference/sdk-rust.mdx
  • docs/architecture/channels.mdx
  • docs/architecture/trigger-types.mdx
  • docs/examples/conditions.mdx
  • docs/examples/cron.mdx
  • docs/examples/hello-world.mdx
  • docs/examples/multi-trigger.mdx
  • docs/examples/observability.mdx
  • docs/examples/state-management.mdx
  • docs/examples/todo-app.mdx
  • docs/how-to/create-custom-trigger-type.mdx
  • docs/how-to/create-ephemeral-worker.mdx
  • docs/how-to/dead-letter-queues.mdx
  • docs/how-to/expose-http-endpoint.mdx
  • docs/how-to/manage-state.mdx
  • docs/how-to/react-to-state-changes.mdx
  • docs/how-to/schedule-cron-task.mdx
  • docs/how-to/stream-realtime-data.mdx
  • docs/how-to/use-functions-and-triggers.mdx
  • docs/how-to/use-queues.mdx
  • docs/how-to/use-trigger-conditions.mdx
  • docs/modules/module-cron.mdx
  • docs/modules/module-pubsub.mdx
  • docs/modules/module-state.mdx
  • docs/modules/module-stream.mdx
  • engine/README.md
  • sdk/README.md
  • sdk/packages/rust/iii/src/protocol.rs
  • sdk/packages/rust/iii/tests/api_triggers.rs
  • sdk/packages/rust/iii/tests/bridge.rs
  • sdk/packages/rust/iii/tests/data_channels.rs
  • sdk/packages/rust/iii/tests/healthcheck.rs
  • sdk/packages/rust/iii/tests/http_external_functions.rs
  • sdk/packages/rust/iii/tests/init_api.rs
  • sdk/packages/rust/iii/tests/pubsub.rs
  • sdk/packages/rust/iii/tests/queue_integration.rs
  • sdk/packages/rust/iii/tests/state.rs

@guibeira
Copy link
Contributor Author

merged this pr into #1332

@guibeira guibeira closed this Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant