Rust Programming

9237 readers
1 users here now

founded 7 years ago
MODERATORS
1
 
 
[features]
default = ["runtime_completion_gen", "comptime_completion_gen", "comptime_manpage_gen"]
runtime_completion_gen = ["dep:clap_complete",]
comptime_completion_gen = ["dep:clap_complete"]
comptime_manpage_gen = ["dep:clap_mangen"]

[dependencies]
anyhow = "1.0.0"
clap = { version = "4.0.0", features = ["derive", "help"] }
clap_complete = { version = "4.0.0", optional = true }
ignore = "0.4.25"

[build-dependencies]
clap = { version = "4.0.0", features = ["derive"] }
clap_complete = { version = "4.0.0", optional = true }
clap_mangen = { version = "0.2.31", optional = true }

The features that start with comptime, as their name suggest, happen at comp time in build.rs, they generate shell completions and manpages for my cli utility, thus they depend only at build time to their respective dependencies, but there seems no way to specify this.

Does anyone know if there is a way to specify build deps for a feature?

2
3
 
 

cross-posted from: https://lemmy.ml/post/45214693

Also vm repo

4
 
 

cross-posted from: https://vger.social/post/37291894

godot-rust goes into the next round with v0.5, just released on crates.io!

On the toolchain side:

  • We now support Rust edition 2024 and Godot 4.6 out of the box, as well as all versions >= 4.2.

  • WebAssembly support no longer needs LLVM/bindgen and is being unit-tested on CI.

  • It's now possible to depend on other godot-rust crates through rlib.

Some features added in this cycle:

Typed dictionary. Also, enums in Godot collections!

let tiles: Dictionary<Vector2i, Tile> = dict! {
   Vector2i::new(1, 2) => Tile::GRASS,
   Vector2i::new(1, 3) => Tile::WATER,
};

Non-null engine APIs:

// Instead of...
let t: Gd<Tween> = node.create_tween().unwrap();
// ...now:
let t: Gd<Tween> = node.create_tween();

Direct == &str comparison, saving allocation:

let s = StringName::from("hello");
if s == "hello" { ... }

Bitfield Debug impl:

assert_eq!(
    format!("{flags:?}"),
    "PropertyUsageFlags { EDITOR | READ_ONLY }"
);

Optional parameters -- call from GDScript as method(1) or method(1, 2):

#[func]
fn method(
    required: i32,
    #[opt(default = 100)] optional: i32,
) { ... }

Export tool button -- click in Godot's inspector to immediately execute Rust code:

#[export_tool_button(fn = Self::on_clicked, icon = "2DNodes")]
click_me: PhantomVar<Callable>, // not a physical property

We now also have a Games page showcasing projects that users made with godot-rust! And I'm still behind on adding new entries there :)

Huge thanks to the community for making this possible! Countless bug reports, PRs, and feedback based on real-world projects have helped godot-rust immensely to reach this point.

If you like the project, consider giving us a star on GitHub. As it's maintained entirely in free time without any financial backing, small GitHub Sponsor contributions are also very appreciated (Yarwin or TitanNano or Bromeon). Thanks to everyone supporting the project -- We are excited to see what will be built on v0.5!

5
6
1
Synchi - Two-way file sync (jakobkreft.github.io)
submitted 3 weeks ago by jak0b@lemmy.ml to c/rust@lemmy.ml
 
 

cross-posted from: https://lemmy.ml/post/44815211

Two-way file sync, no remote agent needed

Today Synchi is finally public! It's designed for syncing files between two locations (local or over SSH). It detects conflicts, and lets you decide what to do.

Why not rsync/Unison/Syncthing?

  • rsync has no memory between runs and is one-way
  • Unison needs to be installed on both sides
  • Syncthing requires always-on daemons

Synchi runs on demand, works over SSH, and only transfers what actually changed.

I use it daily for syncing a shared folder between my machines and an android phone. Works great in combination with Tailscale/WireGuard so that you can sync files remotely.

7
8
 
 

Always had the problem that if I wanted to just log an error, rather than bubble it all the way up to main(), that you wouldn't get a stacktrace. You could iterate the source chain and plug the stacktrace together yourself, but it's rather complex code.

Now I realized, you can do this to get a stacktrace:

let error = todo!("Get an error somehow...");
let error = anyhow::anyhow!(error); //converts to an `anyhow::Error`
eprintln!("Error with stacktrace: {error:?}");

For converting to an anyhow::Error, it often also makes sense to use anyhow::Context like so:

use anyhow::Context;
let error = error.context("Deleting file failed.");
9
10
 
 

Hello rust!

I’ve recently wanted to create a blog with Gemini, but I have a very strong disdain for writing boilerplate. It’s a scar that has never left me since HTML. Instead, I JUST wanted to write the content, and not have to worry much about writing the same layout (though it matters less than in HTML).

Therefore, I created gtm with the knowledge that no one else tried doing the same thing I was doing. I ended up proving myself wrong after discovering Michael Lazar’s Jetforce, which is currently a much more complete project than my own. However, I still believe that working on it would result in something interesting.

This project was originally written in Python due to Jinja2, rich, click, and other libraries. However, I rewrote the program in Rust because I wanted more control over the context my plugins were going to run in. I've found that clap, anyhow and tera did what I want well enough :).

Feel free to let me know if you want anything added to this. Currently, Lua is something I really want to add to gtm since I want people to be able to write their own functionality. I’d be glad to see what you lot have to say.

A side note before anyone gets curious, I wrote this entirely by hand as my first major project, and is also being used for me to learn Rust. No LLMs, GPTs, AI-powered smart fridges or similar were involved.

Cheers!

11
 
 

Hi, some time ago I made a driver for STM32WLE5JC’s subGHz device in Rust, which communicates via internal SPI lines. Right now it can do RX/TX with LoRa, (G)FSK, (G)MSK and TX with BPSK, and today I decided to share it :3

It’s not yet finished and there’s some things I’d still like to do, including meeting the (boring) radio laws worldwide, or publishing it on crates.io. It’s my first project like that and I hope it’ll be helpful to someone.

I also wrote a blog post series covering the subGHz radio, my programming process and I also touched on some other interesting stuff like demodulation basics with GNU Radio. I learned so much and I hope others will find it interesting as well!

Here are the blog posts :3 go read them >:3

https://lusia.moe/tags/stm32wle5jc/

12
 
 

cross-posted from: https://sh.itjust.works/post/57050433

Hello

I've been interested with Rust for the last year, but cannot find time to learn Rust.

Coming from Python, i have found my self quite difficult to learn Rust and grasp its concepts.

So, for the last couple of weeks, i have been able to spare some times to learn Rust, and created a mini project to parse Vendor OUI with Rust.

If you would be so kind to spare some of your time to review my code and give me some constructive feedback on how to tackle this, and some guidance for me about what i can improve because its not the rust way of doing things, i would be very happy. I want to improve my skills on Rust so i have another tools in my toolbox

This is not a promotion, because i believe there's another tools just like mine out there nor i want you to use my project, because this project is only for me to test my skill for using Rust.

Thank you in advanced :D

13
14
15
16
 
 

Visualizes a proof or program written in mathematical programming language Lean. Written with Rust and backend in Lean.

https://codeberg.org/wvhulle/lean-tui

17
 
 

So I ran cargo audit on a project and got the following output:

error: 4 vulnerabilities found!
warning: 8 allowed warnings found

What do I do to fix these errors? The vulnerabilities are in dependencies of my dependencies, and they seem to be using an older version of a package. Is my only option to upgrade my own dependencies (which would take a non-trivial amount of work), or is there any way to tell my dependencies to use a newer version of those vulnerable packages like how npm audit fix works? I'm guessing that's what cargo audit fix is supposed to do, but in my case it wasn't able to fix any of the vulnerabilities.

I tried searching the web, but there was surprisingly little information on this stuff.

18
 
 

In this example, all todo operations — from simple CRUD to tasks own instructions — are executed by a virtual machine.

The concept is that any kind of automation or workflow can be enabled by task instructions executed by the VM, rather than hardcoded functions in the app. It’s close to the concept of rules engines.

There are 4 demo task instructions:

  • chain - Creates next task once when another completes. Removes calldata after call - called once
  • either - Sets complete if either one or another task is completed + deletes not completed task (see gif)
  • destructable - task self destructs when it's status set to complete
  • hide - Keeps task hidden while specified task's status is not complete.

It is possible to add your own instructions to calldata.toml and use them within todo example:

cargo run -- add <TASK_TITLE > -calldata <INSTRUCTION_NAME> <PARAMETERS>

repo: https://github.com/tracyspacy/spacydo

todo example : https://github.com/tracyspacy/spacydo/tree/main/examples/todo

19
 
 

cross-posted from: https://programming.dev/post/45148310

Supac is a declarative package manager written in Rust fully scriptable in nushell. It's meant to make it easy to use the native package managers in existing distros without going through the associated headaches of using Nix, while maintaining the ergonomics of structured data in nushell.

Currently supported backends are:

  • Archlinux and derivatives
  • flatpak
  • cargo/cargo-binstall
  • uvx (packages only for now)
  • rustup toolchains

I daily drive it, and it works well. Feel free to give it a try!

20
 
 

cross-posted from: https://programming.dev/post/45042537

cross-posted from: https://programming.dev/post/45042331

Hello again!!

Sorry for the big delay in the announcements. I know it has been a long time I have not made any announcements but I will try my best next time this doesn't happen again.

So, through the medium of this post I would like to share with you all the v1.24.36 major release version of the websurfx project which was released on the 26th of January.

If you are new, and you don't know what is websurfx then I would suggest taking a look at my previous post here:

https://programming.dev/post/2678496

Which covers in depth about what the project is and why it exists.

Credits

Before I share with you the changelog, what this release version means and a preview on what we are planning to work on for the next major release v2.0.0. I would first like to thank all our contributors and maintainers because of whom this was all possible. Specially I would like to thank spencerjibz, MickLesk and SchweGELBin who have been invaluable to the project. Also, Websurfx would not have been possible without alamin655 and xffxff early involvement.

thanks Thanks 💖 to all the people involved in the project

Now, let's dive straight into what this release version actually means.

What does this release version means

This new release version v1.24.36 updates the hybrid caching api to take advantage of the two layer caching solution which eliminates the round trip time delay of fetching the same results from the cache.

Changelog

The changelog of all the changes can be found here:

https://github.com/neon-mmd/websurfx/releases/tag/v1.24.36

Preview of the goals for the next major release

  • Different levels of privacy to choose from with the help of rust's conditional compiling features (In progress).
  • Even more engines will be supported.
  • Categories would be added to search results like images, news, etc.
  • More themes will be provided by default
  • More animations for the websurfx frontend will be supported.
  • Multi language support would be added.
  • I2p and tor support will be provided.
  • Reduce animations would be added for those who don't want animations and effects on the frontend.
  • And lots more ✨.

Call To Action

If you love our project and want to see it move ahead and progress in the direction you want, then we would suggest contributing at our project

21
 
 

Recent updates:

  • VM now uses NaN-boxing technique.
  • All stack values are 64-bit (u64) but encode 5 distinct types: Boolean, String, CallData, U32, and MemSlice (25-bit offset + 25-bit size). code
  • Added InlineVec — a vector-like structure backed by a fixed-size array. The VM stack, control stack, call stack, and jump stack now use it with defined limits. code
  • VM now has a heap memory. Memory is simple Vec, grows dynamically, but technically length is restricted by mem_slice_val format: 25 bits payload for offset and size

Project is still in absolutely early stage.

22
 
 
23
1
Announcing Rust 1.93.0 (blog.rust-lang.org)
submitted 2 months ago by Ephera@lemmy.ml to c/rust@lemmy.ml
 
 

Seems like another routine release. At least no huge surprises that I'm seeing...

24
 
 

Managarr v0.7.0 has been released with Lidarr support!

What is Managarr?

Managarr is a terminal-based application for managing all your Servarr instances from one place. It provides a user-friendly interface to interact with your media libraries, making it easier to manage your downloads, monitor your artists and albums, and perform various actions directly from the terminal.

It sports two modes: a TUI mode (Text-based User Interface) and a CLI mode (Command Line Interface).

TUI mode gives you an interactive User Interface right inside your terminal window, allowing you to navigate through your Sonarr and Radarr libraries, view details about your series and movies, and perform actions like adding or removing items, all through keyboard shortcuts.

CLI mode lets you execute commands directly from the terminal to manage your Servarr instances without needing to open the TUI. This is great for quick tasks or for integrating with scripts and automation tools.

Screenshots

Try it out for yourself using the in-browser demo!

If you want to try it out for yourself without installing it first, you can use the Managarr demo-site: https://managarr-demo.alexjclarke.com/

What Lidarr operations are supported?

📚 Library Management

  • Artist Library - Browse, search, filter, and sort your music collection
  • Add Artists ➕ - Search for new artists and add them with full config options (quality profile, metadata profile, root folder, monitoring options)
  • Edit Artists ✏️ - Tweak artist settings including quality profiles, metadata profiles, tags, and monitoring status
  • Delete Artists 🗑️ - Remove artists from your library with optional file deletion
  • Artist Details 🔍 - Get the full picture on any artist:
    • Overview, disambiguation, type, status, genres, and ratings
    • Album list with release dates, track counts, and download status
    • Artist history with detailed event info
    • Manual discography search with release selection and download

💿 Album & Track Management

  • Album Details - Drill into individual albums to see:
    • Track listing with audio info (codec, channels, bitrate, sample rate, bit depth)
    • Album history
    • Manual album search for grabbing specific releases
  • Track Details 🎼 - View individual track info and history
  • Delete Albums - Remove individual albums from your library

⬇️ Downloads & Queue

  • Downloads Tab - Keep an eye on active downloads and manage your queue
  • Blocklist 🚫 - View and manage blocked releases

📜 History

  • Full History Support - Browse, search, filter, and sort Lidarr event history
  • History Details - Dig into the details of any history event
  • Mark as Failed ❌ - Mark history items as failed

🔎 Indexers

  • Indexer Management - View, add, edit, and delete indexers
  • Indexer Settings ⚙️ - Configure global indexer settings
  • Test Indexers 🧪 - Test individual or all indexers at once

📁 Root Folders

  • Root Folder Management - Add and manage root folders for your music library

🖥️ System

  • System Status - View Lidarr system info and health checks
  • Tasks - View and trigger system tasks
  • Queued Events - Monitor queued system events
  • Logs 📋 - Browse system logs
  • Updates 🆙 - Check for and view available updates

⌨️ CLI Commands

Full Lidarr CLI support for all the things!

managarr lidarr list artists|albums|tracks|indexers|root-folders|tags|quality-profiles|...
managarr lidarr get artist|album|track|...
managarr lidarr add artist|root-folder|tag|...
managarr lidarr edit artist|indexer|indexer-settings|...
managarr lidarr delete artist|album|root-folder|tag|blocklist-item|...
managarr lidarr search artist|album|...
managarr lidarr refresh artist|downloads|...
managarr lidarr trigger-automatic-search artist|album
managarr lidarr manual-search artist|album

Managarr also supports Radarr and Sonarr!

If you're running the full *arr stack, Managarr has you covered - It supports Radar and Sonarr too, all from the same interface!

This is a passion project so I'd love to hear your feedback, feature requests, or any bug reports you find.

25
view more: next ›