bitcoinleveldb_table/
handle.rs

1crate::ix!();
2
3/**
4  | 1-byte type + 32-bit crc
5  |
6  */
7pub const BLOCK_TRAILER_SIZE: usize = 5;
8
9pub struct BlockContents {
10
11    /**
12      | Actual contents of data
13      |
14      */
15    data:           Slice,
16
17    /**
18      | True iff data can be cached
19      |
20      */
21    cachable:       bool,
22
23    /**
24      | True iff caller should delete[] data.data()
25      |
26      */
27    heap_allocated: bool,
28}
29
30/**
31  | BlockHandle is a pointer to the extent
32  | of a file that stores a data block or a
33  | meta block.
34  |
35  */
36#[derive(Default)]
37pub struct BlockHandle {
38    offset: u64,
39    size:   u64,
40}
41
42/**
43  | Maximum encoding length of a BlockHandle
44  |
45  */
46pub const BLOCK_HANDLE_MAX_ENCODED_LENGTH: usize = 10 + 10;
47
48impl BlockHandle {
49
50    /**
51      | The offset of the block in the file.
52      |
53      */
54    pub fn offset(&self) -> u64 {
55        
56        todo!();
57        /*
58            return offset_;
59        */
60    }
61    
62    pub fn set_offset(&mut self, offset: u64)  {
63        
64        todo!();
65        /*
66            offset_ = offset;
67        */
68    }
69
70    /**
71       The size of the stored block
72      */
73    pub fn size(&self) -> u64 {
74        
75        todo!();
76        /*
77            return size_;
78        */
79    }
80    
81    pub fn set_size(&mut self, size: u64)  {
82        
83        todo!();
84        /*
85            size_ = size;
86        */
87    }
88    
89    /**
90      | Implementation details follow. Clients
91      | should ignore,
92      |
93      */
94    pub fn new() -> Self {
95
96        todo!();
97        /*
98           : offset_(~static_cast<uint64_t>(0)), size_(~static_cast<uint64_t>(0))
99           */
100    }
101    
102    pub fn encode_to(&self, dst: *mut String)  {
103        
104        todo!();
105        /*
106            // Sanity check that all fields have been set
107      assert(offset_ != ~static_cast<uint64_t>(0));
108      assert(size_ != ~static_cast<uint64_t>(0));
109      PutVarint64(dst, offset_);
110      PutVarint64(dst, size_);
111        */
112    }
113    
114    pub fn decode_from(&mut self, input: *mut Slice) -> crate::Status {
115        
116        todo!();
117        /*
118            if (GetVarint64(input, &offset_) && GetVarint64(input, &size_)) {
119        return Status::OK();
120      } else {
121        return Status::Corruption("bad block handle");
122      }
123        */
124    }
125}
126