Skip to content

feat: State trait, pattern, doc, examples#1331

Merged
vobradovich merged 1 commit into
masterfrom
vo/state-traits
Apr 29, 2026
Merged

feat: State trait, pattern, doc, examples#1331
vobradovich merged 1 commit into
masterfrom
vo/state-traits

Conversation

@vobradovich
Copy link
Copy Markdown
Member

Two traits for abstracting over state storage:

  • State — read access; read(&self) -> Result<impl Deref<Target = Item>, Error>
  • StateMut: State — write access; write(&mut self) -> Result<impl DerefMut<Target = Item>, Error>

@vobradovich vobradovich self-assigned this Apr 28, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the State and StateMut traits to abstract over state storage, enabling services to be generic over their state handles. It refactors example services like CounterService and Validator to use these traits, adds comprehensive unit tests, and fixes a recurring typo ("Substract") in IDL and client files. Feedback identifies a breaking change caused by the premature adoption of the Rust 2024 edition in the prelude, a compatibility issue with core::error::Error on older Rust versions, and a suggestion for more explicit dereferencing in the replace_with method.

Comment thread rs/src/prelude.rs
Comment thread rs/src/state.rs
Comment thread rs/src/state.rs
@vobradovich vobradovich requested a review from m62624 April 29, 2026 08:49
@vobradovich vobradovich merged commit 4806eb2 into master Apr 29, 2026
8 of 9 checks passed
@vobradovich vobradovich deleted the vo/state-traits branch April 29, 2026 13:45
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.

2 participants