Rust Programming

9208 readers
3 users here now

founded 7 years ago
MODERATORS
1
2
 
 

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.

3
4
 
 

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.");
5
6
 
 

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!

7
 
 

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/

8
 
 

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

9
10
11
12
 
 

Hi everyone! I want to introduce a project that I’ve been working on for 6 days with ARandomOSDever. It currently has only a few layout functions: Spacing, Direction (Row, Column), Padding, Margin, Min/Max Size, Align, and it already supports no std. I’m sharing this with you to get feedback, both good and bad. I would really appreciate your thoughts

GitHub repo: https://github.com/dest-hq/axes

Crates: https://crates.io/crates/axes

I’m not entirely sure, yet why Axes performs faster than Taffy, maybe it’s because Taffy has many layout functions that affect performance.

Here’s a benchmark (Axes 0.2.0 vs Taffy 0.9.2).

| Benchmark | Axes | Taffy | Difference | |


|


|


|


| | Tree: 1,000 Nodes | 15.889 µs | 89.114 µs | 460.853% | | Tree: 10,000 Nodes | 1.1744 ms | 1.0698 ms | -8.90668% | | Tree: 100,000 Nodes | 8.7379 ms | 33.083 ms | 278.615% | | Compute: 1,000 Nodes | 17.423 µs | 39.317 µs | 125.661% | | Compute: 10,000 Nodes | 176.51 µs | 446.35 µs | 152.875% | | Compute: 100,000 Nodes | 1.7988 ms | 14.976 ms | 732.555% |

Hope you have an awesome day

13
 
 

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

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

14
 
 

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.

15
 
 

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

16
 
 

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!

17
 
 

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

18
 
 

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.

19
 
 
20
31
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...

21
 
 

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.

22
23
 
 

I've been building a bytecode VM in Rust and recently implemented NaN boxing for value representation. Sharing here for anyone interested.

I needed all VM values (booleans, integers, string pool indices, bytecode references) to fit in 64 bits (stack is Vec).

My implementation encodes 5 distinct types using a 3-bit tag and 32-bit payload, all within a single u64. It also has 15 unused bits, they may be used later for types expansion.

I'm using a 64-bit layout:

  • Bits 63-51: Quiet NaN signature (0x7FFC...)
  • Bits 50-18: 32-bit payload (integers, string pool indices, etc.)
  • Bits 17-3: Unused/ (15 bits)
  • Bits 2-0: 3-bit type tag

So it allows me to have 5 tagged types: TRUE_VAL, FALSE_VAL, STRING_VAL, CALLDATA_VAL, U32_VAL

24
 
 

Here is my winter holiday project. Current scope and known issues are listed in readme, so thoughts and ideas on them are welcome ^_^

25
 
 

cross-posted from: https://beehaw.org/post/23996175

Website: https://yazi-rs.github.io/

Changelog: https://github.com/sxyazi/yazi/blob/main/CHANGELOG.md#v251229

They have lot of stuff:

  • Added for new features.
  • Changed for changes in existing functionality.
  • Deprecated for soon-to-be removed features.
  • Fixed for any bug fixes.
  • Improved for performance improvements.

I just list the first 10 added stuff:

[v25.12.29]

Added

  • Remote file management ([#3396])
  • Virtual file system ([#3034], [#3035], [#3094], [#3108], [#3187], [#3203])
  • Shell formatting ([#3232])
  • Multi-entry support for plugin system ([#3154])
  • Zoom in or out of the preview image ([#2864])
  • Improve the UX of the pick and input components ([#2906], [#2935])
  • Show progress of each task in task manager ([#3121], [#3131], [#3134])
  • New fs.copy() and fs.rename() APIs ([#3467])
  • New experimental ya.async() API ([#3422])
  • New overall option to set the overall background color ([#3317])
  • ... and more!
view more: next ›