1use context_interface::LocalContextTr;
3use core::cell::RefCell;
4use std::{rc::Rc, vec::Vec};
5
6#[derive(Clone, Debug)]
8pub struct LocalContext {
9 pub shared_memory_buffer: Rc<RefCell<Vec<u8>>>,
11}
12
13impl Default for LocalContext {
14 fn default() -> Self {
15 Self {
16 shared_memory_buffer: Rc::new(RefCell::new(Vec::with_capacity(1024 * 4))),
17 }
18 }
19}
20
21impl LocalContextTr for LocalContext {
22 fn clear(&mut self) {
23 unsafe { self.shared_memory_buffer.borrow_mut().set_len(0) };
25 }
26
27 fn shared_memory_buffer(&self) -> &Rc<RefCell<Vec<u8>>> {
28 &self.shared_memory_buffer
29 }
30}
31
32impl LocalContext {
33 pub fn new() -> Self {
35 Self::default()
36 }
37}