bitcoinleveldb_batch/
write_batch_alt.rs

1crate::ix!();
2
3///----------------
4pub struct MemTableInserter {
5    sequence: SequenceNumber,
6    mem:      *mut MemTable,
7}
8
9impl WriteBatchHandler for MemTableInserter {
10
11}
12
13impl WriteBatchPut for MemTableInserter {
14
15    fn put(&mut self, 
16        key_:   &Slice,
17        value: &Slice)  {
18        
19        todo!();
20        /*
21            mem_->Add(sequence_, kTypeValue, key, value);
22        sequence_++;
23        */
24    }
25}
26
27impl WriteBatchDelete for MemTableInserter {
28
29    fn delete(&mut self, key_: &Slice)  {
30        
31        todo!();
32        /*
33            mem_->Add(sequence_, kTypeDeletion, key, Slice());
34        sequence_++;
35        */
36    }
37}
38
39//-------------------------------------------[.cpp/bitcoin/src/leveldb/db/write_batch_internal.h]
40
41/**
42  | WriteBatchInternal provides static
43  | methods for manipulating a WriteBatch
44  | that we don't want in the public WriteBatch
45  | interface.
46  |
47  */
48pub struct WriteBatchInternal {
49
50}
51
52impl WriteBatchInternal {
53
54    pub fn insert_into(&mut self, 
55        b:        *const WriteBatch,
56        memtable: *mut MemTable) -> crate::Status {
57        
58        todo!();
59        /*
60            MemTableInserter inserter;
61      inserter.sequence_ = WriteBatchInternal::Sequence(b);
62      inserter.mem_ = memtable;
63      return b->Iterate(&inserter);
64        */
65    }
66    
67    pub fn set_contents(&mut self, 
68        b:        *mut WriteBatch,
69        contents: &Slice)  {
70        
71        todo!();
72        /*
73            assert(contents.size() >= kHeader);
74      b->rep_.assign(contents.data(), contents.size());
75        */
76    }
77    
78    pub fn append(&mut self, 
79        dst: *mut WriteBatch,
80        src: *const WriteBatch)  {
81        
82        todo!();
83        /*
84            SetCount(dst, Count(dst) + Count(src));
85      assert(src->rep_.size() >= kHeader);
86      dst->rep_.append(src->rep_.data() + kHeader, src->rep_.size() - kHeader);
87        */
88    }
89
90    /**
91      | Return the number of entries in the batch.
92      |
93      */
94    pub fn count(&mut self, b: *const WriteBatch) -> i32 {
95        
96        todo!();
97        /*
98            return DecodeFixed32(b->rep_.data() + 8);
99        */
100    }
101    
102    /**
103      | Set the count for the number of entries
104      | in the batch.
105      |
106      */
107    pub fn set_count(&mut self, 
108        b: *mut WriteBatch,
109        n: i32)  {
110        
111        todo!();
112        /*
113            EncodeFixed32(&b->rep_[8], n);
114        */
115    }
116    
117    /**
118      | Return the sequence number for the start
119      | of this batch.
120      |
121      */
122    pub fn sequence(&mut self, b: *const WriteBatch) -> SequenceNumber {
123        
124        todo!();
125        /*
126            return SequenceNumber(DecodeFixed64(b->rep_.data()));
127        */
128    }
129    
130    /**
131      | Store the specified number as the sequence
132      | number for the start of this batch.
133      |
134      */
135    pub fn set_sequence(&mut self, 
136        b:   *mut WriteBatch,
137        seq: SequenceNumber)  {
138        
139        todo!();
140        /*
141            EncodeFixed64(&b->rep_[0], seq);
142        */
143    }
144
145    pub fn contents(batch: *const WriteBatch) -> Slice {
146        
147        todo!();
148        /*
149            return Slice(batch->rep_);
150        */
151    }
152    
153    pub fn byte_size(batch: *const WriteBatch) -> usize {
154        
155        todo!();
156        /*
157            return batch->rep_.size();
158        */
159    }
160}