tuwunel_database/map/
count.rs1use std::{fmt::Debug, sync::Arc};
2
3use futures::stream::StreamExt;
4use serde::Serialize;
5use tuwunel_core::implement;
6
7#[implement(super::Map)]
12#[inline]
13pub fn count(self: &Arc<Self>) -> impl Future<Output = usize> + Send + '_ {
14 self.raw_keys().count()
15}
16
17#[implement(super::Map)]
26#[inline]
27pub fn count_from<'a, P>(
28 self: &'a Arc<Self>,
29 from: &P,
30) -> impl Future<Output = usize> + Send + 'a + use<'a, P>
31where
32 P: Serialize + ?Sized + Debug + 'a,
33{
34 self.keys_from_raw(from).count()
35}
36
37#[implement(super::Map)]
42#[inline]
43pub fn raw_count_from<'a, P>(
44 self: &'a Arc<Self>,
45 from: &'a P,
46) -> impl Future<Output = usize> + Send + 'a
47where
48 P: AsRef<[u8]> + ?Sized + Debug + Sync + 'a,
49{
50 self.raw_keys_from(from).count()
51}
52
53#[implement(super::Map)]
62#[inline]
63pub fn count_prefix<'a, P>(
64 self: &'a Arc<Self>,
65 prefix: &P,
66) -> impl Future<Output = usize> + Send + 'a + use<'a, P>
67where
68 P: Serialize + ?Sized + Debug + 'a,
69{
70 self.keys_prefix_raw(prefix).count()
71}
72
73#[implement(super::Map)]
78#[inline]
79pub fn raw_count_prefix<'a, P>(
80 self: &'a Arc<Self>,
81 prefix: &'a P,
82) -> impl Future<Output = usize> + Send + 'a
83where
84 P: AsRef<[u8]> + ?Sized + Debug + Sync + 'a,
85{
86 self.raw_keys_prefix(prefix).count()
87}