Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::io::{Read};
- const CHUNK_SIZE: u32 = 5000;
- // Decoder takes data from a Readable source en decodes it
- struct Decoder<R: Read> {
- input: R
- }
- impl<R: Read> Decoder<R> {
- pub fn new(src: R) -> Self {
- Self {
- input: src
- }
- }
- }
- pub struct LasZipDecompressor<R: Read> {
- input: R,
- decoder: Decoder<&mut R>,
- chunk_points_read: u32,
- }
- impl<R: Read> LasZipDecompressor<R> {
- pub fn new(mut source: R) -> Self {
- Self {
- // source is moved into input
- input: source,
- // how to borrow input and not source
- decoder: Decoder::new(&mut source),
- chunk_points_read: 0,
- }
- }
- pub fn decompress_one(&mut self, out: &mut[u8]) {
- if self.chunk_points_read == 0 {
- self.reset_decoder();
- }
- // decoder.foo(&mut out);
- self.chunk_points_read += 1;
- if self.chunk_points_read == CHUNK_SIZE {
- self.chunk_points_read = 0;
- }
- }
- fn reset_decoder(&mut self) {
- self.decoder = Decoder::new(&mut self.input);
- }
- }
- fn main() {
- let laszip = LasZipDecompressor::new(std::io::Cursor::new(Vec::<u8>::new()));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement