danyel

joined 1 year ago
 

[disclaimer: initially posted on Reddit r/rust]

unrar is a library for listing and extracting RAR archives.

Hi lemmyrs!

Almost 8 years ago, I release my first Rust crate. Today, before I leave Reddit at the end of the month due to the recent controversy, after months and years working on and off on this update, as a parting gift, I'm happy to announce the crate's biggest release ever. This really is a milestone release that, among others, allows one to extract files directly into memory -- something people have been asking forever how to do.

I've also completely rewritten major parts of the library and am very proud of the way things are looking right now. Utilizing the typestate pattern, the library enforces correct usage at compile time, only exposing methods when they make sense (depending on a combination of open mode and current cursor position).

Before this release, the library was hard to use and it was not possible to skip some files in the archive while, for instance, extracting others. One operation had to be chosen for all files. That has changed now. However, the drawback is that iterating archives is now a bit harder since the Iterator trait is not implemented for archives that are opened in Process mode (since it's hard to enforce an operation at call-site). I have a few ideas how to improve this going forward but input is also always welcome.

Anyway, this sets the groundwork architecture and paves the way forward for upcoming releases where ergonomics and other improvements like error types can be the focus.

Another major focus of this release was documentation: all API items are documented now except for very few exceptions. The crate docs also features a very extensible introduction as well.

GitHub repository can be found here: https://github.com/muja/unrar.rs

Feel free to discuss / ask questions here or over on Reddit.

Thanks!

 

[disclaimer: initially posted on Reddit r/rust]

unrar is a library for listing and extracting RAR archives.

Hi lemmyrs!

Almost 8 years ago, I release my first Rust crate. Today, before I leave Reddit at the end of the month due to the recent controversy, after months and years working on and off on this update, as a parting gift, I'm happy to announce the crate's biggest release ever. This really is a milestone release that, among others, allows one to extract files directly into memory -- something people have been asking forever how to do.

I've also completely rewritten major parts of the library and am very proud of the way things are looking right now. Utilizing the typestate pattern, the library enforces correct usage at compile time, only exposing methods when they make sense (depending on a combination of open mode and current cursor position).

Before this release, the library was hard to use and it was not possible to skip some files in the archive while, for instance, extracting others. One operation had to be chosen for all files. That has changed now. However, the drawback is that iterating archives is now a bit harder since the Iterator trait is not implemented for archives that are opened in Process mode (since it's hard to enforce an operation at call-site). I have a few ideas how to improve this going forward but input is also always welcome.

Anyway, this sets the groundwork architecture and paves the way forward for upcoming releases where ergonomics and other improvements like error types can be the focus.

Another major focus of this release was documentation: all API items are documented now except for very few exceptions. The crate docs also features a very extensible introduction as well.

GitHub repository can be found here: https://github.com/muja/unrar.rs

Feel free to discuss / ask questions here or over on Reddit.

Thanks!

 

[disclaimer: initially posted on Reddit r/rust]

unrar is a library for listing and extracting RAR archives.

Hi lemmyrs!

Almost 8 years ago, I release my first Rust crate. Today, before I leave Reddit at the end of the month due to the recent controversy, after months and years working on and off on this update, as a parting gift, I'm happy to announce the crate's biggest release ever. This really is a milestone release that, among others, allows one to extract files directly into memory -- something people have been asking forever how to do.

I've also completely rewritten major parts of the library and am very proud of the way things are looking right now. Utilizing the typestate pattern, the library enforces correct usage at compile time, only exposing methods when they make sense (depending on a combination of open mode and current cursor position).

Before this release, the library was hard to use and it was not possible to skip some files in the archive while, for instance, extracting others. One operation had to be chosen for all files. That has changed now. However, the drawback is that iterating archives is now a bit harder since the Iterator trait is not implemented for archives that are opened in Process mode (since it's hard to enforce an operation at call-site). I have a few ideas how to improve this going forward but input is also always welcome.

Anyway, this sets the groundwork architecture and paves the way forward for upcoming releases where ergonomics and other improvements like error types can be the focus.

Another major focus of this release was documentation: all API items are documented now except for very few exceptions. The crate docs also features a very extensible introduction as well.

GitHub repository can be found here: https://github.com/muja/unrar.rs

Feel free to discuss / ask questions here or over on Reddit.

Thanks!

[โ€“] danyel@lemmyrs.org 0 points 1 year ago (1 children)

First of all, thank you for this very elaborate answer. So that means OnceCell can never be used in a static but only as local variable / member variable? I see, that makes sense and also reduces its use cases by a lot of what I initially thought. But your example makes sense and the name/package also suggest it's not thread-safe in itself, I had just wrongly assumed OnceCell was meant to be used in static contexts.

Thanks!

 

I've been using lazy_static until now but was trying to migrate to OnceCell. It seems I can't have a OnceCell even though I'm never calling mutable methods on the regex. I'm not even using multiple threads.

The error I'm getting is:

Any way to solve this or do I have to use OnceLock / continue using lazy_static? I don't want to add the overhead of using OnceLock if not necessary.

[โ€“] danyel@lemmyrs.org 1 points 1 year ago

Sorry but am I missing something? What's there to struggle with println("Hello Cargo")?