226
26
submitted 2 years ago by tracyspcy@lemmy.ml to c/rust@lemmy.ml
227
24
228
3
submitted 2 years ago* (last edited 2 years ago) by ozoned@lemmy.world to c/rust@lemmy.ml

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

229
61
submitted 2 years ago by nutomic@lemmy.ml to c/rust@lemmy.ml

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

230
39
submitted 2 years ago by Sibbo@sopuli.xyz to c/rust@lemmy.ml
231
28
submitted 2 years ago by Sibbo@sopuli.xyz to c/rust@lemmy.ml
232
9
submitted 2 years ago* (last edited 2 years ago) by marsuplane@lemmy.world to c/rust@lemmy.ml

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 !mles@lemmy.world. Thanks!

233
7

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!

234
7
submitted 3 years ago* (last edited 2 years ago) by pr06lefs@lemmy.ml to c/rust@lemmy.ml

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?

235
22
submitted 3 years ago* (last edited 3 years ago) by jack@monero.town to c/rust@lemmy.ml

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

236
9
submitted 3 years ago* (last edited 3 years ago) by force@lemmy.world to c/rust@lemmy.ml

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...

237
15
submitted 3 years ago by dindresto@lemmy.korz.dev to c/rust@lemmy.ml

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 nixrust@rheinneckar.events 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

238
20
submitted 3 years ago by jplatte@discuss.tchncs.de to c/rust@lemmy.ml
239
27
Axum 0.7 released (github.com)
submitted 3 years ago by milliams@lemmy.world to c/rust@lemmy.ml

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

240
-2
submitted 3 years ago by nyanbinary@lemmy.ml to c/rust@lemmy.ml

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.

241
52
Announcing Rust 1.74.0 (blog.rust-lang.org)
submitted 3 years ago by clot27@lemm.ee to c/rust@lemmy.ml
242
55
Bevy 0.12 (bevyengine.org)
submitted 3 years ago by Shatur@lemmy.ml to c/rust@lemmy.ml
243
19
submitted 3 years ago by KaczuH@lemmy.ml to c/rust@lemmy.ml

Interesting stack

244
32
submitted 3 years ago* (last edited 3 years ago) by KaczuH@lemmy.ml to c/rust@lemmy.ml
245
37
submitted 3 years ago* (last edited 3 years ago) by nyl@lemmy.opensupply.space to c/rust@lemmy.ml

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.

246
31
submitted 3 years ago by Sibbo@sopuli.xyz to c/rust@lemmy.ml

A nice and long read about the history of async Rust. Gives a nice set of reasons for why it is as it is now.

I would still hope though that Rust would be more bold when it comes to making breaking changes that improve the language in the future. Given that the edition system was made exactly for that.

247
13
submitted 3 years ago by Sibbo@sopuli.xyz to c/rust@lemmy.ml
248
14

I'm curious as to how the hashbrown crate can have up to 2x performance on certain operations, even though it looks like the standard library's HashMap is just a wrapper for hashbrown.

I understand that a wrapper could add a small overhead, but 50% of the original performance is a bit silly, especially considering all of the functions in the wrapper are #[inline], so there should be no overhead in calling most functions.

Does anyone know the reason for this?

249
33
submitted 3 years ago by wolf4ood@lemmy.ml to c/rust@lemmy.ml
250
48
submitted 3 years ago by Azadi@lemmy.ml to c/rust@lemmy.ml
view more: ‹ prev next ›

Rust Programming

9435 readers
1 users here now

founded 7 years ago
MODERATORS