1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Apache License, Version 2.0. See LICENSE.txt in the project root for license information.
* This software incorporates material from third parties. See NOTICE.txt for details.
*--------------------------------------------------------------------------------------------*/
pub struct PreflateInput<'a> {
data: &'a [u8],
pos: i32,
}
impl<'a> PreflateInput<'a> {
pub fn new(v: &'a [u8]) -> Self {
PreflateInput { data: v, pos: 0 }
}
pub fn pos(&self) -> u32 {
self.pos as u32
}
pub fn size(&self) -> u32 {
self.data.len() as u32
}
pub fn cur_chars(&self, offset: i32) -> &[u8] {
&self.data[(self.pos + offset) as usize..]
}
pub fn cur_char(&self, offset: i32) -> u8 {
self.data[(self.pos + offset) as usize]
}
pub fn advance(&mut self, l: u32) {
self.pos += l as i32;
}
pub fn remaining(&self) -> u32 {
self.data.len() as u32 - self.pos as u32
}
}