Rust Programming

7734 readers
12 users here now

founded 5 years ago
MODERATORS
51
58
submitted 6 months ago* (last edited 6 months ago) by [email protected] to c/[email protected]
 
 

I am delighted to finally release a project that has been cooking for quite a while: Yarn Spinner for Rust 🎉 . Some of you might remember this under the name Yarn Slinger, but the kind folks at Secret Lab have allowed me to use their trademark! Yay!

What is Yarn Spinner?

It's a friendly tool that helps you write dialog! See for yourself at the live demo. You can also check out this or this GDC talk about the original C# implementation. What I have released today is the Rust port for the project, with first-class support for Bevy!

Quickstart

Writing a dialog with Yarn Spinner is as easy as whipping up a simple screenplay:

// assets/dialogue/hello_world.yarn
title: Start
***
Ancient Reptilian Brain: There is nothing. Only warm, primordial blackness. Your conscience ferments in it -- no larger than a single grain of malt. You don't have to do anything anymore.
Ancient Reptilian Brain: Ever.
Ancient Reptilian Brain: Never ever.
-> Never ever ever?
  Ancient Reptilian Brain: Never ever ever ever, baby!
-> (Simply keep on non-existing.)

Ancient Reptilian Brain: An inordinate amount of time passes. It is utterly void of struggle. No ex-wives are contained within it. 
===

Pretty simple file format, right? Check out the general Yarn Spinner documentation for more or look into the Bevy examples.

52
 
 

I made it for myself as the simplest way to keep track of positive routines. The concept is simple: Track the activities that make up your perfect day and monitor your daily progress effortlessly. Here is also a github link for those who interested : https://github.com/tracyspacy/yacht

53
 
 

Maybe 2024 will be the year I rebuild everything in @rust

54
 
 

cross-posted from: https://lemmy.world/post/11271385

Basically, you can choose some slides from an opened .tex file to copy. It also has the function to see which graphics files are included in the selected files, so you know which ones to copy.

Here is the Github link: https://github.com/Atreyagaurav/beamer-quickie

The PDF pages are shown using the SyncTeX (if available) so that you can visually choose the slides as long as there is a single .tex source file, (might still work without synctex for simple cases).

I've made it on Linux, so it hasn't been tested in windows. You probably will need to compile gtk on Windows if you want to make it work. So if someone is really interested let me know, I can give instructions. Even in linux you'll need to install dependencies.

55
 
 

I am new to Rust, and have always been interested in how games were made. But man I've got to say that just ready the bevy book has been pretty fun. I am looking at all the examples in the repo. I wanna here others perspective on bevy, or Rust game development in general!

crossposted from: https://programming.dev/post/8881051

56
57
58
3
submitted 7 months ago* (last edited 7 months ago) by [email protected] to c/[email protected]
 
 

cross-posted from: https://lemmy.world/post/10459323

Live coding Matrix in Rust #owncast #streaming #coding #rust #matrix

Find Andy’s previous recordings at: https://diode.zone/a/andybalaam/video-channels

59
 
 

This library is responsible for federation in Lemmy, and can also be used by other Rust projects.

60
61
62
9
submitted 8 months ago* (last edited 8 months ago) by [email protected] to c/[email protected]
 
 

Hi! Mles (Modern Lightweight channEl Service) protocol with Rust-based reference implementation is on the path to upgrade to v2. The new version will be simpler and more secure. In case interested how to make the protocol v2 draft even better, please join discussion and comment on [email protected]. Thanks!

63
 
 

I've seen a few but I can't decide which protocol to use yet. I'm working on a DHT pet project and I'd like to avoid making it rely on any relay servers.

Thanks in advance for any pointers!

64
 
 

Ed: solved with the help of the async_stream crate.

I'm struggling with the borrow checker!

My problem: I'm using actix-web and rusqlite. I want to return an unlimited number of records from an rusqlite query, and actix provides a Stream trait for that kind of thing. You just impl the trait and return your records from a poll_next() fn.

On the rusqlite side, there's this query_map that returns an iterator of records from a query. All I have to do is smush these two features together.

So the plan is to put the iterator returned by query_map into a struct that impls Stream. Problem is the lifetime of a var used by query_map. How to make the var have the same lifetime as the iterator??

So here's the code:

pub struct ZkNoteStream<'a, T> {
  rec_iter: Box<dyn Iterator<Item = T> + 'a>,
}

// impl of Stream just calls next() on the iterator.  This compiles fine.
impl<'a> Stream for ZkNoteStream<'a, serde_json::Value> {
  type Item = serde_json::Value;

  fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
    Poll::Ready(self.rec_iter.next())
  }
}

// init function to set up the ZkNoteStream.
impl<'a> ZkNoteStream<'a, Result<ZkListNote, rusqlite::Error>> {
  pub fn init(
    conn: &'a Connection,
    user: i64,
    search: &ZkNoteSearch,
  ) -> Result<Self, Box<dyn Error>> {
    let (sql, args) = build_sql(&conn, user, search.clone())?;

    let sysid = user_id(&conn, "system")?;
    let mut pstmt = conn.prepare(sql.as_str())?;

    // Here's the problem!  Borrowing pstmt.
    let rec_iter = pstmt.query_map(rusqlite::params_from_iter(args.iter()), move |row| {
      let id = row.get(0)?;
      let sysids = get_sysids(&conn, sysid, id)?;
      Ok(ZkListNote {
        id: id,
        title: row.get(1)?,
        is_file: {
          let wat: Option<i64> = row.get(2)?;
          wat.is_some()
        },
        user: row.get(3)?,
        createdate: row.get(4)?,
        changeddate: row.get(5)?,
        sysids: sysids,
      })
    })?;

    Ok(ZkNoteStream::<Result<ZkListNote, rusqlite::Error>> {
      rec_iter: Box::new(rec_iter),
    })
  }
}

And here's the error:

error[E0515]: cannot return value referencing local variable `pstmt`
   --> server-lib/src/search.rs:170:5
    |
153 |       let rec_iter = pstmt.query_map(rusqlite::params_from_iter(args.iter()), move |row| {
    |                      ----- `pstmt` is borrowed here
...
170 | /     Ok(ZkNoteStream::<Result<ZkListNote, rusqlite::Error>> {
171 | |       rec_iter: Box::new(rec_iter),
172 | |     })
    | |______^ returns a value referencing data owned by the current function

So basically it boils down to pstmt getting borrowed in the query_map call. It needs to have the same lifetime as the closure. How do I ensure that?

65
22
submitted 8 months ago* (last edited 8 months ago) by [email protected] to c/[email protected]
 
 

UPDATE: I found this issue explaining the relicensing of rust game engine Bevy to MIT + Apache 2.0 dual. Tldr: A lot of rust projects are MIT/Apache 2.0 so using those licenses is good for interoperability and upstreaming. MIT is known and trusted and had great success in projects like Godot.

ORIGINAL POST:

RedoxOS, uutils, zoxide, eza, ripgrep, fd, iced, orbtk,...

It really stands out considering that in FOSS software the GPL or at least the LGPL for toolkits is the most popular license

Most of the programs I listed are replacements for stuff we have in the Linux ecosystem, which are all licensed under the (L)GPL:

uutils, zoxide, eza, ripgrep, fd -> GNU coreutils (GPL)

iced, orbtk -> GTK, QT (LGPL)

RedoxOS -> Linux kernel, most desktop environments like GNOME, KDE etc. all licensed GPL as much as possible

66
9
submitted 8 months ago* (last edited 8 months ago) by [email protected] to c/[email protected]
 
 

I find that a lot of libraries tend to be Linux-focused and generally kind of ugly on Windows, so what do you use when you want to make something that looks nice and performs well on Windows?

The best looking ones I've seen were web frontends like in Tauri. A runner up would maybe be iced-rs. Which is a shame because I really wanted to use relm or fltk-rs but it looks like I'd almost have to use the web renderer to get "sleek, sexy" GUIs...

67
 
 

We are starting a new meetup group for the Rhein-Neckar-Region in Heidelberg, Germany.

The first event will take place on December 19 at the University's Mathematikon.

The twist is that we're beginning with a dual-topic meetup: Nix & Rust.

As there is some overlap between the two communities and we couldn't decide for which of the two we'd rather organize a meetup, we went for both in one.

The meetup is organized through the regional Mobilizon instance: https://rheinneckar.events/events/298e520c-89ca-4754-96f8-e252b96b7a46

Please sign up if you plan on attending so we can make sure there is enough space for all participants. Also feel free to drop an email at [email protected] or a Mastodon message at https://rheinneckar.social/@NixRust if you would like to become a speaker for the meetup, be it with a NixOS or Rust topic, or a combination of both!

The current (tentative) schedule:

  • 18:30 - Open Doors

  • 19:00 - Greeting

  • 19:05 - An Introduction to Nix

  • 19:30 - Second Talk (Rust related)

  • 20:00 - Networking and get together

68
69
 
 

This is the new release of Axum, the first to use the also newly-released hyper 1.0.

70
 
 

I'm a complete beginner in programming with no prior experience, and I want a tutor/mentor to learn Rust for software(GUI, games, software in general) development and, eventually, kernel development(microkernels, IPC, specifically). I pay, of course. (Also, another note, I dislike UNIX (philosophy wise), so I would be looking to get experience in non-UNIX kernel development but also learn UNIX stuff as well.) Furthermore, to note, is I'm interested in game development.

I have a document from my previous tutor in this outlining the stuff I am keen to learn, practically a syllabus, so if you want to see it dm me :3.

71
72
50
Bevy 0.12 (bevyengine.org)
submitted 9 months ago by [email protected] to c/[email protected]
73
 
 

Interesting stack

74
75
 
 

In practical perspectives, I'm mostly concerned about computer resources usage; I have computer resources constraints. So using Rust would benefit on that. But it is for a Web application backend. So, is it worth it having to learn Rust + Tokio + Axum, ... in this specific situation? Also, that this is mostly for initially prototyping an application. Also considering if I add developers in the future, they would most likely not be familiar with Rust, but with more popular frameworks such as Node.

view more: ‹ prev next ›