Git Product home page Git Product logo

ic-rust-starter's Introduction

ic-rust-starter

I often find myself making the same edits to the dfx new -type rust starter template. This alternative starter template contains the following:

  • Different directory structure without a frontend
  • Automatic Candid file generation if you run cargo test
  • A global State object using the thread_local pattern which is saved in stable memory across updates
  • An example of a update and query call
  • Updated release profile based on this great blog post about Effective Rust canisters
  • A devcontainer configuration so you can install the entire needed toolchain with a single click in vscode based on this tutorial (needs docker)

โš ๏ธ Sadly the devcontainer does not work on ARM macs. Please open an issue if you experience issues on other platforms as I couldn't test those

Getting started

  1. clone the repo and open in vscode
  2. If you don't have an M1/M2 mac click the tooltip that shows up to start the devcontainer
  3. in the devcontainer terminal run `dfx start --background"
  4. run dfx deploy

If you do have an M1 of M2 mac

  1. clone the repo and open in vscode and do not click the popup
  2. remove the .devcontainer directory
  3. make sure you have rust toolchain installed
  4. run `dfx start --background"
  5. run dfx deploy

Changing the project name

To give the project your desired project name just run a find and replace on all instances of starter to your_project_name and change the name of the starter directory and the starter.did file to your_project_name and your_project_name.did as well.


Final tip: You can add additional fields to your structs accross upgrades if you wrap the new field values with the Option type. Otherwise you will get an error in the post_upgrade hook and the upgrade will fail.

Feel free to open up an issue if you'd like an example of different concepts as well.

ic-rust-starter's People

Stargazers

Fabio Biola avatar Mark avatar Moritz Fuller avatar Luca Bertelli avatar

Watchers

Moritz Fuller avatar  avatar Fulco avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.