1#[cfg(feature = "serde")]
5use serde::{Deserialize, Serialize};
6
7#[derive(Debug, Clone, PartialEq, Eq)]
9#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
10pub struct NeoStorageContext {
11 id: u32,
12 read_only: bool,
13}
14
15impl NeoStorageContext {
16 pub fn new(id: u32) -> Self {
17 Self {
18 id,
19 read_only: false,
20 }
21 }
22
23 pub fn with_read_only(id: u32, read_only: bool) -> Self {
24 Self { id, read_only }
25 }
26
27 pub fn read_only(id: u32) -> Self {
28 Self {
29 id,
30 read_only: true,
31 }
32 }
33
34 pub fn id(&self) -> u32 {
35 self.id
36 }
37
38 pub fn is_read_only(&self) -> bool {
39 self.read_only
40 }
41
42 pub fn as_read_only(&self) -> Self {
43 Self {
44 id: self.id,
45 read_only: true,
46 }
47 }
48}