web3api_wasm_rs/msgpack/
data_view.rs1use crate::Context;
2use std::io::Cursor;
3
4#[derive(Debug)]
5pub struct DataView {
6 pub(crate) buffer: Cursor<Vec<u8>>,
7 pub(crate) context: Context,
8}
9
10impl DataView {
11 pub fn new(buf: &[u8], context: Context) -> Result<Self, String> {
12 Ok(Self {
13 buffer: Cursor::new(buf.to_vec()),
14 context,
15 })
16 }
17
18 pub fn get_buffer(&self) -> Vec<u8> {
19 self.buffer.clone().into_inner()
20 }
21
22 pub fn context(&mut self) -> &mut Context {
23 &mut self.context
24 }
25}