Git Product home page Git Product logo

rust_resource_viewer's Introduction

Resource Viewer

Simple project to help with learning rust

Demo recording

Reason for making this:

Rather than continuing to read about or watch videos about rust, I mostly built this project to actually build something with rust.

I definitely made a lot of newbie mistakes.

Issues I ran into:

I had problems with lifetimes where some of the variables in the Charts could outlive the data if the data were created inside the functions. For instance, in the function cpu_block, if I created the vec that would be passed into the dataset inside the function, I would receive an error that the vec is dropped when the function ends, but the chart would live on because it is returned and ownership is transferred. The solution I came up with is extremely hacky as I ended up just putting the data inside the state.

I also definitely didn't follow the right structure for using the tui create, as my app state was not being stored in the right place. I think there is a way to directly embed it in the terminal or frame. This might have solved some of the lifetimes issues but I'm not sure.

I wasn't sure how best to share data between threads, as I ended up having the system data being updated in a different thread than the main render loop. I ended up using an Arc with a RwLock. Im not sure if this is the best approach or if there is something else that would have less overhead.

Things I enjoyed:

It was a lot simpler than I expected, most likely due to how well made the tui crate is.

When writing in rust, since the type system is so extensive, if my code compiles, then it usually just worked as intended.

The error messages were very clear and showed exactly why it was erroring.

Things I didn't enjoy:

While the error messages were very descriptive, for the more complex/uncommon errors, such as the lifetimes issues I ran into. It wasn't clear what I could do to fix it.

The number of online resources available isn't on the same scale as more popular languages such as JS/TS. This meant that I spent more time looking for an answer to something than I would usually spend on another language.

The traits systems are sometimes confusing, when trying to access a trait on the Networks struct, I could see in the source code it was there, but I couldn't use it which was very confusing. It turned out you have to add use sysinfo::NetworkExt; to use those traits. This pattern is probably something you get used to but can be very confusing to begin with.

Usage:

To run this locally you would need to clone to repo, then run cargo run, this requires rust and cargo to be installed on your system.

rust_resource_viewer's People

Contributors

daryanka avatar

Watchers

 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.