You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've tried to decode some data from a &[u8] into a alloc::vec::Vec<u8>. 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:
#![no_std]externcrate alloc;// use standard allocatorfndecode_my_data(input:&[u8]) -> Result<alloc::vec::Vec<u8>,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:
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.
The text was updated successfully, but these errors were encountered:
Hello--
you can't use the Read interface with no_std, so you have two choices
a) to fall back to the more basic C-like interface (or the C interface itself)
b) to use the CustomIO implementations, where you provide the nostd reader
match brotli_decompressor::BrotliDecompressCustomIo(&mut r, // pass in the Read-like reader
&mut w, // pass in the output Write-like writer
&mut alloc_u8.alloc_cell(buffer_size).slice_mut(), // pass in the input and output fixed buffers
&mut alloc_u8.alloc_cell(buffer_size).slice_mut(),
alloc_u8, // pass in some allocators
alloc_u32,
alloc_hc,
Error::new(ErrorKind::UnexpectedEof, "Unexpected EOF")) { // you also need to provide the error type
Err(e) => Err(e),
Ok(()) => {
... your data has been written to the writer
},
}
I've tried to decode some data from a
&[u8]
into aalloc::vec::Vec<u8>
. For some reason, this crate requiresstd::io::Read
- but that trait is not available onno_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: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 supportno_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 inmalloc
andfree
function pointers instead of this generic mess: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 implementingstd::io::Read
- which is not available onno_std
. I tried to port thedecode
function by copying the implementation in theRead
trait, but for some reason the code uses things likeinput_buffer
as an output buffer and does some copy-in-place tricks, which is confusing. Maybe it's possible to run it onno_std
, but the code is simply too complex for me to know which traits / types I should use. I'd appreciate any help / examples.The text was updated successfully, but these errors were encountered: