1#![allow(clippy::type_complexity)]
2
3use std::{collections::BTreeMap, hash::BuildHasher};
4
5use either::Either;
6use indexmap::IndexMap;
7use smallvec_wrapper::OneOrMore;
8
9pub mod types {
11 use super::*;
12 use cheap_clone::CheapClone;
13
14 pub struct KeyRef<'a, K: 'a> {
16 pub key: &'a K,
18 pub version: u64,
20 }
21
22 impl<'a, K: 'a> KeyRef<'a, K> {
23 pub fn key(&self) -> &K {
25 self.key
26 }
27
28 pub fn version(&self) -> u64 {
32 self.version
33 }
34 }
35
36 pub enum Item<'a, K, V, B, O> {
38 Pending(EntryRef<'a, K, V>),
41 Borrowed(B),
44 Owned(O),
47 }
48
49 impl<'a, K, V, B, O> Item<'a, K, V, B, O> {
50 pub fn unwrap_pending(&self) -> EntryRef<'a, K, V> {
55 match self {
56 Item::Pending(item) => *item,
57 _ => panic!("expected pending item"),
58 }
59 }
60
61 pub fn unwrap_borrow(&self) -> &B {
66 match self {
67 Item::Borrowed(item) => item,
68 _ => panic!("expected borrowed item"),
69 }
70 }
71
72 pub fn unwrap_owned(self) -> O {
77 match self {
78 Item::Owned(item) => item,
79 _ => panic!("expected owned item"),
80 }
81 }
82
83 pub fn unwrap_owned_ref(&self) -> &O {
88 match self {
89 Item::Owned(item) => item,
90 _ => panic!("expected owned item"),
91 }
92 }
93
94 pub fn unwrap_committed(self) -> Either<B, O> {
99 match self {
100 Item::Borrowed(item) => Either::Left(item),
101 Item::Owned(item) => Either::Right(item),
102 _ => panic!("expected committed item"),
103 }
104 }
105
106 pub fn unwrap_committed_ref(&self) -> Either<&B, &O> {
111 match self {
112 Item::Borrowed(item) => Either::Left(item),
113 Item::Owned(item) => Either::Right(item),
114 _ => panic!("expected committed item"),
115 }
116 }
117 }
118
119 pub struct EntryRef<'a, K, V> {
121 pub data: EntryDataRef<'a, K, V>,
122 pub version: u64,
123 }
124
125 impl<'a, K: core::fmt::Debug, V: core::fmt::Debug> core::fmt::Debug for EntryRef<'a, K, V> {
126 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
127 f.debug_struct("EntryRef")
128 .field("version", &self.version)
129 .field("data", &self.data)
130 .finish()
131 }
132 }
133
134 impl<'a, K, V> Clone for EntryRef<'a, K, V> {
135 fn clone(&self) -> Self {
136 *self
137 }
138 }
139
140 impl<'a, K, V> Copy for EntryRef<'a, K, V> {}
141
142 impl<'a, K, V> EntryRef<'a, K, V> {
143 #[inline]
145 pub const fn data(&self) -> &EntryDataRef<'a, K, V> {
146 &self.data
147 }
148
149 #[inline]
151 pub const fn value(&self) -> Option<&V> {
152 match self.data {
153 EntryDataRef::Insert { value, .. } => Some(value),
154 EntryDataRef::Remove(_) => None,
155 }
156 }
157
158 #[inline]
162 pub const fn version(&self) -> u64 {
163 self.version
164 }
165 }
166
167 pub enum EntryDataRef<'a, K, V> {
169 Insert {
171 key: &'a K,
173 value: &'a V,
175 },
176 Remove(&'a K),
178 }
179
180 impl<'a, K: core::fmt::Debug, V: core::fmt::Debug> core::fmt::Debug for EntryDataRef<'a, K, V> {
181 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
182 match self {
183 Self::Insert { key, value } => f
184 .debug_struct("Insert")
185 .field("key", key)
186 .field("value", value)
187 .finish(),
188 Self::Remove(key) => f.debug_tuple("Remove").field(key).finish(),
189 }
190 }
191 }
192
193 impl<'a, K, V> Clone for EntryDataRef<'a, K, V> {
194 fn clone(&self) -> Self {
195 *self
196 }
197 }
198
199 impl<'a, K, V> Copy for EntryDataRef<'a, K, V> {}
200
201 pub enum EntryData<K, V> {
203 Insert {
205 key: K,
207 value: V,
209 },
210 Remove(K),
212 }
213
214 impl<K, V> EntryData<K, V> {
215 #[inline]
217 pub const fn key(&self) -> &K {
218 match self {
219 Self::Insert { key, .. } => key,
220 Self::Remove(key) => key,
221 }
222 }
223 }
224
225 impl<K: core::fmt::Debug, V: core::fmt::Debug> core::fmt::Debug for EntryData<K, V> {
226 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
227 match self {
228 Self::Insert { key, value } => f
229 .debug_struct("Insert")
230 .field("key", key)
231 .field("value", value)
232 .finish(),
233 Self::Remove(key) => f.debug_tuple("Remove").field(key).finish(),
234 }
235 }
236 }
237
238 impl<K, V> Clone for EntryData<K, V>
239 where
240 K: Clone,
241 V: Clone,
242 {
243 fn clone(&self) -> Self {
244 match self {
245 Self::Insert { key, value } => Self::Insert {
246 key: key.clone(),
247 value: value.clone(),
248 },
249 Self::Remove(key) => Self::Remove(key.clone()),
250 }
251 }
252 }
253
254 impl<K, V> CheapClone for EntryData<K, V>
255 where
256 K: CheapClone,
257 V: CheapClone,
258 {
259 fn cheap_clone(&self) -> Self {
260 match self {
261 Self::Insert { key, value } => Self::Insert {
262 key: key.cheap_clone(),
263 value: value.cheap_clone(),
264 },
265 Self::Remove(key) => Self::Remove(key.cheap_clone()),
266 }
267 }
268 }
269
270 pub struct Entry<K, V> {
272 pub version: u64,
273 pub data: EntryData<K, V>,
274 }
275
276 impl<K: core::fmt::Debug, V: core::fmt::Debug> core::fmt::Debug for Entry<K, V> {
277 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
278 f.debug_struct("Entry")
279 .field("version", &self.version)
280 .field("data", &self.data)
281 .finish()
282 }
283 }
284
285 impl<K, V> Clone for Entry<K, V>
286 where
287 K: Clone,
288 V: Clone,
289 {
290 fn clone(&self) -> Self {
291 Self {
292 version: self.version,
293 data: self.data.clone(),
294 }
295 }
296 }
297
298 impl<K, V> CheapClone for Entry<K, V>
299 where
300 K: CheapClone,
301 V: CheapClone,
302 {
303 fn cheap_clone(&self) -> Self {
304 Self {
305 version: self.version,
306 data: self.data.cheap_clone(),
307 }
308 }
309 }
310
311 impl<K, V> Entry<K, V> {
312 #[inline]
314 pub const fn data(&self) -> &EntryData<K, V> {
315 &self.data
316 }
317
318 #[inline]
320 pub const fn version(&self) -> u64 {
321 self.version
322 }
323
324 #[inline]
326 pub fn into_components(self) -> (u64, EntryData<K, V>) {
327 (self.version, self.data)
328 }
329
330 #[inline]
332 pub fn key(&self) -> &K {
333 match &self.data {
334 EntryData::Insert { key, .. } => key,
335 EntryData::Remove(key) => key,
336 }
337 }
338
339 pub fn split(self) -> (K, EntryValue<V>) {
341 let Entry { data, version } = self;
342
343 let (key, value) = match data {
344 EntryData::Insert { key, value } => (key, Some(value)),
345 EntryData::Remove(key) => (key, None),
346 };
347 (key, EntryValue { value, version })
348 }
349
350 pub fn unsplit(key: K, value: EntryValue<V>) -> Self {
352 let EntryValue { value, version } = value;
353 Entry {
354 data: match value {
355 Some(value) => EntryData::Insert { key, value },
356 None => EntryData::Remove(key),
357 },
358 version,
359 }
360 }
361 }
362
363 pub struct EntryValue<V> {
365 pub version: u64,
367 pub value: Option<V>,
369 }
370
371 impl<V: core::fmt::Debug> core::fmt::Debug for EntryValue<V> {
372 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
373 f.debug_struct("EntryValue")
374 .field("version", &self.version)
375 .field("value", &self.value)
376 .finish()
377 }
378 }
379
380 impl<V> Clone for EntryValue<V>
381 where
382 V: Clone,
383 {
384 fn clone(&self) -> Self {
385 Self {
386 version: self.version,
387 value: self.value.clone(),
388 }
389 }
390 }
391
392 impl<V> CheapClone for EntryValue<V>
393 where
394 V: CheapClone,
395 {
396 fn cheap_clone(&self) -> Self {
397 Self {
398 version: self.version,
399 value: self.value.cheap_clone(),
400 }
401 }
402 }
403
404 #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
407 pub struct KeysOptions {
408 pub prefetch_size: usize,
412 pub reverse: bool,
414 pub all_versions: bool,
416 pub since_version: u64,
418 }
419
420 impl Default for KeysOptions {
421 fn default() -> Self {
422 Self::new()
423 }
424 }
425
426 impl KeysOptions {
427 #[inline]
429 pub const fn new() -> Self {
430 Self {
431 prefetch_size: 0,
432 reverse: false,
433 all_versions: false,
434 since_version: 0,
435 }
436 }
437
438 #[inline]
440 pub fn set_prefetch_size(&mut self, prefetch_size: usize) -> &mut Self {
441 self.prefetch_size = prefetch_size;
442 self
443 }
444
445 #[inline]
447 pub const fn with_prefetch_size(mut self, prefetch_size: usize) -> Self {
448 self.prefetch_size = prefetch_size;
449 self
450 }
451
452 #[inline]
454 pub fn set_reverse(&mut self, reverse: bool) -> &mut Self {
455 self.reverse = reverse;
456 self
457 }
458
459 #[inline]
461 pub const fn with_reverse(mut self, reverse: bool) -> Self {
462 self.reverse = reverse;
463 self
464 }
465
466 #[inline]
468 pub fn set_all_versions(&mut self, all_versions: bool) -> &mut Self {
469 self.all_versions = all_versions;
470 self
471 }
472
473 #[inline]
475 pub const fn with_all_versions(mut self, all_versions: bool) -> Self {
476 self.all_versions = all_versions;
477 self
478 }
479
480 #[inline]
482 pub fn set_since_version(&mut self, since_version: u64) -> &mut Self {
483 self.since_version = since_version;
484 self
485 }
486
487 #[inline]
489 pub const fn with_since_version(mut self, since_version: u64) -> Self {
490 self.since_version = since_version;
491 self
492 }
493 }
494
495 #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
498 pub struct IteratorOptions {
499 pub prefetch_size: usize,
503 pub prefetch_values: bool,
509 pub reverse: bool,
511 pub all_versions: bool,
513 pub since_version: u64,
515 }
516
517 impl Default for IteratorOptions {
518 fn default() -> Self {
519 Self::new()
520 }
521 }
522
523 impl IteratorOptions {
524 #[inline]
526 pub const fn new() -> Self {
527 Self {
528 prefetch_size: 0,
529 prefetch_values: false,
530 reverse: false,
531 all_versions: false,
532 since_version: 0,
533 }
534 }
535
536 #[inline]
538 pub fn set_prefetch_size(&mut self, prefetch_size: usize) -> &mut Self {
539 self.prefetch_size = prefetch_size;
540 self
541 }
542
543 #[inline]
545 pub const fn with_prefetch_size(mut self, prefetch_size: usize) -> Self {
546 self.prefetch_size = prefetch_size;
547 self
548 }
549
550 #[inline]
552 pub fn set_prefetch_values(&mut self, prefetch_values: bool) -> &mut Self {
553 self.prefetch_values = prefetch_values;
554 self
555 }
556
557 #[inline]
559 pub const fn with_prefetch_values(mut self, prefetch_values: bool) -> Self {
560 self.prefetch_values = prefetch_values;
561 self
562 }
563
564 #[inline]
566 pub fn set_reverse(&mut self, reverse: bool) -> &mut Self {
567 self.reverse = reverse;
568 self
569 }
570
571 #[inline]
573 pub const fn with_reverse(mut self, reverse: bool) -> Self {
574 self.reverse = reverse;
575 self
576 }
577
578 #[inline]
580 pub fn set_all_versions(&mut self, all_versions: bool) -> &mut Self {
581 self.all_versions = all_versions;
582 self
583 }
584
585 #[inline]
587 pub const fn with_all_versions(mut self, all_versions: bool) -> Self {
588 self.all_versions = all_versions;
589 self
590 }
591
592 #[inline]
594 pub fn set_since_version(&mut self, since_version: u64) -> &mut Self {
595 self.since_version = since_version;
596 self
597 }
598
599 #[inline]
601 pub const fn with_since_version(mut self, since_version: u64) -> Self {
602 self.since_version = since_version;
603 self
604 }
605 }
606}
607
608pub mod sync {
610 use super::{types::*, *};
611
612 pub trait PendingManager: 'static {
622 type Error: std::error::Error + 'static;
624 type Key: 'static;
626 type Value: 'static;
628
629 fn is_empty(&self) -> bool;
631
632 fn len(&self) -> usize;
634
635 fn get(&self, key: &Self::Key) -> Result<Option<&EntryValue<Self::Value>>, Self::Error>;
637
638 fn insert(&mut self, key: Self::Key, value: EntryValue<Self::Value>)
640 -> Result<(), Self::Error>;
641
642 fn remove_entry(
644 &mut self,
645 key: &Self::Key,
646 ) -> Result<Option<(Self::Key, EntryValue<Self::Value>)>, Self::Error>;
647
648 fn keys(&self) -> impl Iterator<Item = &'_ Self::Key>;
650
651 fn iter(&self) -> impl Iterator<Item = (&'_ Self::Key, &'_ EntryValue<Self::Value>)>;
653
654 fn into_iter(self) -> impl Iterator<Item = (Self::Key, EntryValue<Self::Value>)>;
656 }
657
658 pub type IndexMapManager<K, V, S = std::hash::RandomState> = IndexMap<K, EntryValue<V>, S>;
660 pub type BTreeMapManager<K, V> = BTreeMap<K, EntryValue<V>>;
662
663 impl<K, V, S> PendingManager for IndexMap<K, EntryValue<V>, S>
664 where
665 K: Eq + core::hash::Hash + 'static,
666 V: 'static,
667 S: BuildHasher + Default + 'static,
668 {
669 type Error = std::convert::Infallible;
670 type Key = K;
671 type Value = V;
672
673 fn is_empty(&self) -> bool {
674 self.is_empty()
675 }
676
677 fn len(&self) -> usize {
678 self.len()
679 }
680
681 fn get(&self, key: &K) -> Result<Option<&EntryValue<V>>, Self::Error> {
682 Ok(self.get(key))
683 }
684
685 fn insert(&mut self, key: K, value: EntryValue<V>) -> Result<(), Self::Error> {
686 self.insert(key, value);
687 Ok(())
688 }
689
690 fn remove_entry(&mut self, key: &K) -> Result<Option<(K, EntryValue<V>)>, Self::Error> {
691 Ok(self.shift_remove_entry(key))
692 }
693
694 fn keys(&self) -> impl Iterator<Item = &K> {
695 self.keys()
696 }
697
698 fn iter(&self) -> impl Iterator<Item = (&K, &EntryValue<V>)> {
699 self.iter()
700 }
701
702 fn into_iter(self) -> impl Iterator<Item = (K, EntryValue<V>)> {
703 core::iter::IntoIterator::into_iter(self)
704 }
705 }
706
707 impl<K, V> PendingManager for BTreeMap<K, EntryValue<V>>
708 where
709 K: Eq + core::hash::Hash + Ord + 'static,
710 V: 'static,
711 {
712 type Error = std::convert::Infallible;
713 type Key = K;
714 type Value = V;
715
716 fn is_empty(&self) -> bool {
717 self.is_empty()
718 }
719
720 fn len(&self) -> usize {
721 self.len()
722 }
723
724 fn get(&self, key: &K) -> Result<Option<&EntryValue<Self::Value>>, Self::Error> {
725 Ok(self.get(key))
726 }
727
728 fn insert(&mut self, key: K, value: EntryValue<Self::Value>) -> Result<(), Self::Error> {
729 self.insert(key, value);
730 Ok(())
731 }
732
733 fn remove_entry(
734 &mut self,
735 key: &K,
736 ) -> Result<Option<(K, EntryValue<Self::Value>)>, Self::Error> {
737 Ok(self.remove_entry(key))
738 }
739
740 fn keys(&self) -> impl Iterator<Item = &K> {
741 self.keys()
742 }
743
744 fn iter(&self) -> impl Iterator<Item = (&K, &EntryValue<Self::Value>)> {
745 self.iter()
746 }
747
748 fn into_iter(self) -> impl Iterator<Item = (K, EntryValue<Self::Value>)> {
749 core::iter::IntoIterator::into_iter(self)
750 }
751 }
752
753 pub trait Database: Sized + 'static {
755 type Error: std::error::Error + 'static;
757 type Options;
759 type Key: core::fmt::Debug + 'static;
761 type Value: core::fmt::Debug + 'static;
763 type Item: 'static;
765 type ItemRef<'a>
767 where
768 Self: 'a;
769 type Iterator<'a>
771 where
772 Self: 'a;
773 type Keys<'a>
775 where
776 Self: 'a;
777
778 fn max_batch_size(&self) -> u64;
780
781 fn max_batch_entries(&self) -> u64;
783
784 fn estimate_size(&self, entry: &Entry<Self::Key, Self::Value>) -> u64;
786
787 fn validate_entry(&self, entry: &Entry<Self::Key, Self::Value>) -> Result<(), Self::Error>;
796
797 fn maximum_version(&self) -> u64;
799
800 fn options(&self) -> &Self::Options;
802
803 fn open(opts: Self::Options) -> Result<Self, Self::Error>;
805
806 fn fingerprint(&self, k: &Self::Key) -> u64;
810
811 fn apply(&self, entries: OneOrMore<Entry<Self::Key, Self::Value>>) -> Result<(), Self::Error>;
825
826 fn get(
828 &self,
829 k: &Self::Key,
830 version: u64,
831 ) -> Result<Option<Either<Self::ItemRef<'_>, Self::Item>>, Self::Error>;
832
833 fn iter<'a, 'b: 'a>(
846 &'a self,
847 pending: impl Iterator<Item = EntryRef<'b, Self::Key, Self::Value>> + 'b,
848 transaction_version: u64,
849 opts: IteratorOptions,
850 ) -> Self::Iterator<'a>;
851
852 fn keys<'a, 'b: 'a>(
865 &'a self,
866 pending: impl Iterator<Item = KeyRef<'b, Self::Key>> + 'b,
867 transaction_version: u64,
868 opts: KeysOptions,
869 ) -> Self::Keys<'a>;
870 }
871}
872
873pub mod future {
875 use super::{types::*, *};
876 use core::future::Future;
877
878 pub trait AsyncPendingManager: Send + Sync + 'static {
888 type Error: std::error::Error + Send + Sync + 'static;
890 type Key: Send + Sync + 'static;
892 type Value: Send + Sync + 'static;
894
895 fn is_empty(&self) -> bool;
897
898 fn len(&self) -> usize;
900
901 fn get(
903 &self,
904 key: &Self::Key,
905 ) -> impl Future<Output = Result<Option<&EntryValue<Self::Value>>, Self::Error>> + Send;
906
907 fn insert(
909 &mut self,
910 key: Self::Key,
911 value: EntryValue<Self::Value>,
912 ) -> impl Future<Output = Result<(), Self::Error>> + Send;
913
914 fn remove_entry(
916 &mut self,
917 key: &Self::Key,
918 ) -> impl Future<Output = Result<Option<(Self::Key, EntryValue<Self::Value>)>, Self::Error>> + Send;
919
920 fn keys(&self) -> impl Future<Output = impl Iterator<Item = &'_ Self::Key>> + Send;
922
923 fn iter(
925 &self,
926 ) -> impl Future<Output = impl Iterator<Item = (&'_ Self::Key, &'_ EntryValue<Self::Value>)>> + Send;
927
928 fn into_iter(
930 self,
931 ) -> impl Future<Output = impl Iterator<Item = (Self::Key, EntryValue<Self::Value>)>> + Send;
932 }
933
934 pub type AsyncIndexMapManager<K, V, S = std::hash::RandomState> = IndexMap<K, EntryValue<V>, S>;
936 pub type AsyncBTreeMapManager<K, V> = BTreeMap<K, EntryValue<V>>;
938
939 impl<K, V, S> AsyncPendingManager for IndexMap<K, EntryValue<V>, S>
940 where
941 K: Eq + core::hash::Hash + Send + Sync + 'static,
942 V: Send + Sync + 'static,
943 S: BuildHasher + Default + Send + Sync + 'static,
944 {
945 type Error = std::convert::Infallible;
946 type Key = K;
947 type Value = V;
948
949 fn is_empty(&self) -> bool {
950 self.is_empty()
951 }
952
953 fn len(&self) -> usize {
954 self.len()
955 }
956
957 async fn get(&self, key: &K) -> Result<Option<&EntryValue<V>>, Self::Error> {
958 Ok(self.get(key))
959 }
960
961 async fn insert(&mut self, key: K, value: EntryValue<V>) -> Result<(), Self::Error> {
962 self.insert(key, value);
963 Ok(())
964 }
965
966 async fn remove_entry(&mut self, key: &K) -> Result<Option<(K, EntryValue<V>)>, Self::Error> {
967 Ok(self.shift_remove_entry(key))
968 }
969
970 async fn keys(&self) -> impl Iterator<Item = &K> {
971 self.keys()
972 }
973
974 async fn iter(&self) -> impl Iterator<Item = (&K, &EntryValue<V>)> {
975 self.iter()
976 }
977
978 async fn into_iter(self) -> impl Iterator<Item = (K, EntryValue<V>)> {
979 core::iter::IntoIterator::into_iter(self)
980 }
981 }
982
983 impl<K, V> AsyncPendingManager for BTreeMap<K, EntryValue<V>>
984 where
985 K: Eq + core::hash::Hash + Ord + Send + Sync + 'static,
986 V: Send + Sync + 'static,
987 {
988 type Error = std::convert::Infallible;
989 type Key = K;
990 type Value = V;
991
992 fn is_empty(&self) -> bool {
993 self.is_empty()
994 }
995
996 fn len(&self) -> usize {
997 self.len()
998 }
999
1000 async fn get(&self, key: &K) -> Result<Option<&EntryValue<Self::Value>>, Self::Error> {
1001 Ok(self.get(key))
1002 }
1003
1004 async fn insert(&mut self, key: K, value: EntryValue<Self::Value>) -> Result<(), Self::Error> {
1005 self.insert(key, value);
1006 Ok(())
1007 }
1008
1009 async fn remove_entry(
1010 &mut self,
1011 key: &K,
1012 ) -> Result<Option<(K, EntryValue<Self::Value>)>, Self::Error> {
1013 Ok(self.remove_entry(key))
1014 }
1015
1016 async fn keys(&self) -> impl Iterator<Item = &K> {
1017 self.keys()
1018 }
1019
1020 async fn iter(&self) -> impl Iterator<Item = (&K, &EntryValue<Self::Value>)> {
1021 self.iter()
1022 }
1023
1024 async fn into_iter(self) -> impl Iterator<Item = (K, EntryValue<Self::Value>)> {
1025 core::iter::IntoIterator::into_iter(self)
1026 }
1027 }
1028
1029 pub trait AsyncDatabase: Sized + Send + Sync + 'static {
1031 type Error: std::error::Error + Send + Sync + 'static;
1033 type Options;
1035 type Key: core::fmt::Debug + Send + Sync + 'static;
1037 type Value: core::fmt::Debug + Send + Sync + 'static;
1039 type Item: Send + Sync + 'static;
1041 type ItemRef<'a>: Send + Sync
1043 where
1044 Self: 'a;
1045 type Iterator<'a>: Send + Sync
1047 where
1048 Self: 'a;
1049 type Keys<'a>: Send + Sync
1051 where
1052 Self: 'a;
1053
1054 fn max_batch_size(&self) -> u64;
1056
1057 fn max_batch_entries(&self) -> u64;
1059
1060 fn estimate_size(&self, entry: &Entry<Self::Key, Self::Value>) -> u64;
1062
1063 fn validate_entry(&self, entry: &Entry<Self::Key, Self::Value>) -> Result<(), Self::Error>;
1072
1073 fn maximum_version(&self) -> u64;
1075
1076 fn options(&self) -> &Self::Options;
1078
1079 fn open(opts: Self::Options) -> impl Future<Output = Result<Self, Self::Error>> + Send;
1081
1082 fn fingerprint(&self, k: &Self::Key) -> u64;
1086
1087 fn apply(
1101 &self,
1102 entries: OneOrMore<Entry<Self::Key, Self::Value>>,
1103 ) -> impl Future<Output = Result<(), Self::Error>> + Send;
1104
1105 fn get(
1107 &self,
1108 k: &Self::Key,
1109 version: u64,
1110 ) -> impl Future<Output = Result<Option<Either<Self::ItemRef<'_>, Self::Item>>, Self::Error>> + Send;
1111
1112 fn iter<'a, 'b: 'a>(
1125 &'a self,
1126 pending: impl Iterator<Item = EntryRef<'b, Self::Key, Self::Value>> + 'b,
1127 transaction_version: u64,
1128 opts: IteratorOptions,
1129 ) -> impl Future<Output = Self::Iterator<'a>> + 'a;
1130
1131 fn keys<'a, 'b: 'a>(
1144 &'a self,
1145 pending: impl Iterator<Item = KeyRef<'b, Self::Key>> + 'b,
1146 transaction_version: u64,
1147 opts: KeysOptions,
1148 ) -> impl Future<Output = Self::Keys<'a>> + 'a;
1149 }
1150}