dropbox / dropbox/rust-brotli-decompressor

How do you use this crate on no_std?

Open
#12 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
61
Forks
30
Avg merge
2d 11h
Merged PRs (30d)
10

Description

I've tried to decode some data from a `&[u8]` into a `alloc::vec::Vec`. For some reason, this crate requires `std::io::Read` - but that trait is not available on `no_std`. I've tried for the past two hours to decipher the unreadable mess that is this codebase in order to just write a function like this:

```rust
#![no_std]
extern crate alloc; // use standard allocator
fn decode_my_data(input: &[u8]) -> Result, BrotliError>
```

I'm sorry if this comes off as rude, but the code is completely unreadable, there's no documentation and no examples for `no_std` use-cases, even though it seems that this crate does support `no_std` (it says so in the project description)? Maybe this is due to this crate being written before certain Rust features were available, but still - if you'd want custom allocators, why not just let users pass in `malloc` and `free` function pointers instead of this generic mess:

![wtf](https://user-images.githubusercontent.com/12084016/106903750-ad488400-66fa-11eb-8d91-a4b79f4b4a38.PNG)

Effectively, this crate only compiles on `std` because the code is too much of a mess. It doesn't seem possible to run the decoding function without the buffer implementing `std::io::Read` - which is *not available on `no_std`*. I tried to port the `decode` function by copying the implementation in the `Read` trait, but for some reason the code uses things like `input_buffer` as an output buffer and does some copy-in-place tricks, which is confusing. Maybe it's possible to run it on `no_std`, but the code is simply too complex for me to know which traits / types I should use. I'd appreciate any help / examples.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.