• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

vigna / sux-rs / 24097483404

07 Apr 2026 06:22PM UTC coverage: 71.015% (-1.4%) from 72.384%
24097483404

push

github

vigna
Serialization for lists

6924 of 9750 relevant lines covered (71.02%)

82523075.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/cli.rs
1
/*
2
 * SPDX-FileCopyrightText: 2026 Sebastiano Vigna
3
 *
4
 * SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
5
 */
6

7
//! Shared CLI types for the `vfunc` and `lcp_mmphf` binaries.
8

9
use std::fmt::Display;
10

11
use crate::bits::BitFieldVec;
12
use crate::func::VBuilder;
13
use crate::func::shard_edge::ShardEdge;
14

15
/// Hash types for signed functions.​
16
#[derive(clap::ValueEnum, Clone, Debug)]
17
pub enum HashTypes {
18
    U8,
19
    U16,
20
    U32,
21
    U64,
22
}
23

24
impl Display for HashTypes {
25
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
×
26
        match self {
×
27
            HashTypes::U8 => write!(f, "u8"),
×
28
            HashTypes::U16 => write!(f, "u16"),
×
29
            HashTypes::U32 => write!(f, "u32"),
×
30
            HashTypes::U64 => write!(f, "u64"),
×
31
        }
32
    }
33
}
34

35
/// VBuilder options shared by all function-building CLIs.​
36
#[derive(clap::Args, Debug)]
37
pub struct BuilderArgs {
38
    /// Use this number of threads.​
39
    #[arg(short, long)]
40
    pub threads: Option<usize>,
41
    /// Use disk-based buckets to reduce memory usage at construction time.​
42
    #[arg(short, long)]
43
    pub offline: bool,
44
    /// Sort shards and check for duplicate signatures.​
45
    #[arg(short, long)]
46
    pub check_dups: bool,
47
    /// A 64-bit seed for the pseudorandom number generator.​
48
    #[arg(long)]
49
    pub seed: Option<u64>,
50
    /// The target relative space overhead due to sharding.​
51
    #[arg(long, default_value_t = 0.001)]
52
    pub eps: f64,
53
    /// Always use the low-mem peel-by-signature algorithm (slightly slower).​
54
    #[arg(long)]
55
    pub low_mem: bool,
56
    /// Always use the high-mem peel-by-signature algorithm (slightly faster).​
57
    #[arg(long, conflicts_with = "low_mem")]
58
    pub high_mem: bool,
59
    /// Convert the structure to use unaligned reads (usually faster queries).​
60
    #[arg(long)]
61
    pub unaligned: bool,
62
}
63

64
impl BuilderArgs {
65
    /// Applies these options to a [`VBuilder`].
66
    pub fn configure<D: Send + Sync, S, E: ShardEdge<S, 3>>(
×
67
        &self,
68
        builder: VBuilder<D, S, E>,
69
    ) -> VBuilder<D, S, E> {
70
        let mut builder = builder
×
71
            .offline(self.offline)
×
72
            .check_dups(self.check_dups)
×
73
            .eps(self.eps);
×
74
        if let Some(seed) = self.seed {
×
75
            builder = builder.seed(seed);
×
76
        }
77
        if let Some(threads) = self.threads {
×
78
            builder = builder.max_num_threads(threads);
×
79
        }
80
        if self.low_mem {
×
81
            builder = builder.low_mem(true);
×
82
        }
83
        if self.high_mem {
×
84
            builder = builder.low_mem(false);
×
85
        }
86
        builder
×
87
    }
88

89
    /// Creates and configures a default [`VBuilder`] with [`BitFieldVec`]
90
    /// storage.
91
    pub fn to_builder(&self) -> VBuilder<BitFieldVec<Box<[usize]>>> {
×
92
        self.configure(VBuilder::default())
×
93
    }
94
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc