Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add State derive macro #42

Merged
merged 6 commits into from
Jun 7, 2021
Merged

Add State derive macro #42

merged 6 commits into from
Jun 7, 2021

Conversation

mappum
Copy link
Contributor

@mappum mappum commented Jun 7, 2021

Closes #41

Description:
Adds the updated version of what was formerly the #[state] attribute macro, to allow structs to easily compose children which themselves implement the State trait. Most application-layer development will simply consume APIs from lower-level State implementations, adding methods on top or just exposing the fields.

type Address = [u8; 32];

#[derive(Encode, Decode)]
struct Account {
  balance: u64,
  nonce: u64.
  pubkey: [u8; 32],
}

#[derive(State)]
struct MyState {
  accounts: Map<Address, Account>,
  total_coins: u64,
}

TODO:

@codecov-commenter
Copy link

codecov-commenter commented Jun 7, 2021

Codecov Report

Merging #42 (9cc9de0) into develop (7da16ec) will increase coverage by 0.60%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop      #42      +/-   ##
===========================================
+ Coverage    64.53%   65.13%   +0.60%     
===========================================
  Files           14       14              
  Lines          750      763      +13     
===========================================
+ Hits           484      497      +13     
  Misses         266      266              
Impacted Files Coverage Δ
src/state/mod.rs 100.00% <100.00%> (ø)
tests/derive.rs 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7da16ec...9cc9de0. Read the comment docs.

@mappum mappum marked this pull request as ready for review June 7, 2021 06:18
@mappum mappum merged commit 165a7aa into develop Jun 7, 2021
@mappum mappum deleted the macro branch June 7, 2021 06:18
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.

Write derive macro for State
2 participants