1 /* Copyright 2018 Mozilla Foundation
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 use super::{BinaryReader, OperatorsReader};
17 
18 #[derive(Debug, Copy, Clone)]
19 pub struct InitExpr<'a> {
20     offset: usize,
21     data: &'a [u8],
22 }
23 
24 impl<'a> InitExpr<'a> {
new(data: &[u8], offset: usize) -> InitExpr25     pub fn new(data: &[u8], offset: usize) -> InitExpr {
26         InitExpr { offset, data }
27     }
28 
get_binary_reader<'b>(&self) -> BinaryReader<'b> where 'a: 'b,29     pub fn get_binary_reader<'b>(&self) -> BinaryReader<'b>
30     where
31         'a: 'b,
32     {
33         BinaryReader::new_with_offset(self.data, self.offset)
34     }
35 
get_operators_reader<'b>(&self) -> OperatorsReader<'b> where 'a: 'b,36     pub fn get_operators_reader<'b>(&self) -> OperatorsReader<'b>
37     where
38         'a: 'b,
39     {
40         OperatorsReader::new(self.data, self.offset)
41     }
42 }
43