gtars_refget/store/mod.rs
1//! # RefgetStore
2//!
3//! A store for managing reference genome sequences with support for both
4//! in-memory and disk-backed storage.
5//!
6//! ## Two-Type Design
7//!
8//! - **`RefgetStore`** (wrapper): User-facing type with `&mut self` read methods
9//! that automatically lazy-load data on first access. Use for CLI and scripts.
10//! - **`ReadonlyRefgetStore`** (inner): All reads are `&self`. Suitable for
11//! `Arc<ReadonlyRefgetStore>` in servers. Requires explicit preloading.
12//!
13//! ## Sequence retrieval flows
14//!
15//! Sequence *bytes* can be served three ways, depending on where the data lives
16//! (resident in RAM, a local `.seq` file, or a remote HTTP store) and how much
17//! you want to move over the wire. All three are first-class; choose by access
18//! pattern.
19//!
20//! 1. **Partial read** — `get_substring` / `get_substrings`. Returns the bases
21//! for `[start, end)` as a `String`, reading only the bytes that cover the
22//! region. Source resolution: loaded or resident bytes -> local `.seq`
23//! (positioned read; the whole sequence never enters RAM) -> remote
24//! byte-range (HTTP `Range:` via `open_remote_range`). The whole sequence
25//! never enters RAM and nothing is persisted, so this is the smart default
26//! for sparse, random-access extraction regardless of where the data lives.
27//! A remote-only sequence is served by fetching just the covering bytes; it
28//! does NOT trigger a whole-chromosome download (use flow 3 for that).
29//! Repeated remote reads re-fetch, so promote to flow 3 for repeat-heavy
30//! workloads.
31//!
32//! 2. **Streaming** — `stream_sequence`. Returns a `Read`er over `[start, end)`
33//! and decodes on the fly, so peak memory stays O(1) in the region length.
34//! Source resolution: loaded bytes -> local `.seq` (seek) -> remote
35//! byte-range (HTTP `Range:` via `open_remote_range`). This is the only flow
36//! that pulls a *region* straight from a remote store, fetching just the
37//! covering bytes; nothing is persisted, so repeated remote reads re-fetch.
38//!
39//! 3. **Load & cache** — `load_sequence` / `load_all_sequences` (via
40//! `ensure_sequence_loaded`). Downloads the *whole* `.seq` once, persists it
41//! under the local cache (when `persist_to_disk` is set) and loads it into
42//! RAM. Subsequent reads are served resident (flow 1's first branch) with no
43//! further I/O. Best when the same sequence is read many times; costs a
44//! full-sequence download + allocation up front (a whole chromosome can be
45//! tens of MB encoded), so avoid it for one-off region pulls.
46//!
47//! Flows 1 and 2 need only metadata loaded; flow 3 loads the sequence's
48//! bytes. Remote byte-range (flows 1-2) requires the `http`
49//! feature; without it, only resident and local sources are available.
50//!
51//! ## Write discipline (concurrency)
52//!
53//! A store directory may be written by several processes at once — separate
54//! `gtars refget build` invocations, SLURM jobs, Python callers. Three rules make
55//! that safe; all three live in Rust, because callers routinely bypass any
56//! coordination arranged above it.
57//!
58//! 1. **Per-item files are digest-addressed and lock-free.** A `.seq` file, a
59//! `collections/<digest>.rgsi`, and an FHR sidecar are named by the digest of
60//! their own content, so two writers producing the same file produce the same
61//! bytes. These are written outside any lock — which is what keeps the
62//! expensive part of an import (parsing, digesting, writing hundreds of
63//! thousands of sequences) fully parallel.
64//!
65//! 2. **Writers commit a DELTA under an exclusive lock.** The shared artifacts —
66//! `sequences.rgsi`, `collections.rgci`, the alias TSVs, `rgstore.json` — are
67//! rewritten wholesale, so a writer that serialized its open-time snapshot
68//! would drop every row another writer added in the meantime, and resurrect
69//! every row another writer removed. Instead,
70//! [`ReadonlyRefgetStore::write_index_files`] takes [`lock::StoreLock`] on
71//! `<store>/.rgstore.lock`, re-reads the current on-disk rows, applies only
72//! the changes this handle actually made (see [`PendingChanges`]), and
73//! publishes. A row nobody
74//! touched is never rewritten. The lock is held for the commit only (seconds),
75//! never for the lifetime of the handle (hours) — with one deliberate
76//! exception, the orphan scan in
77//! [`ReadonlyRefgetStore::remove_collection`].
78//!
79//! 3. **Readers never lock.** Every whole-file write goes through
80//! [`atomic::atomic_write`] (temp file, `fsync`, `rename(2)`, `fsync` the
81//! directory), so a reader always sees a complete file. `rgstore.json` is
82//! published LAST in the commit sequence, after the files whose digests it
83//! advertises, so a manifest never describes bytes that have not landed.
84//!
85//! Transient files (`.rgstore.lock`, `.rgstore.lock.stale.*`, `.rgstore.tmp.*`)
86//! may briefly appear in a store directory; anything mirroring or auditing the
87//! directory must skip them (see [`atomic::is_transient_store_file`]).
88
89mod readonly;
90mod core;
91mod alias;
92pub(crate) mod atomic;
93mod catalog;
94mod packidx;
95mod packcache;
96mod fhr_metadata;
97mod lock;
98// FASTA import (crossbeam-channel) and export (gtars-core) are filesystem-only.
99#[cfg(feature = "filesystem")]
100mod import;
101mod persistence;
102#[cfg(feature = "filesystem")]
103mod export;
104mod label;
105mod verify;
106
107// The bulk of the store tests import FASTA via the filesystem-only API.
108#[cfg(all(test, feature = "filesystem"))]
109mod tests;
110
111// Non-filesystem store tests: pure path/template/mode logic that needs no FASTA
112// import, so they run under `--no-default-features`.
113#[cfg(test)]
114mod nofs_tests {
115 use super::*;
116
117 #[test]
118 fn test_expand_template() {
119 let digest = "ABCDEFghijklmnop";
120
121 let result = ReadonlyRefgetStore::expand_template(digest, "sequences/%s2/%s.seq");
122 assert_eq!(result, std::path::PathBuf::from("sequences/AB/ABCDEFghijklmnop.seq"));
123
124 let result = ReadonlyRefgetStore::expand_template(digest, "sequences/%s2/%s4/%s.seq");
125 assert_eq!(result, std::path::PathBuf::from("sequences/AB/ABCD/ABCDEFghijklmnop.seq"));
126
127 let result = ReadonlyRefgetStore::expand_template(digest, "sequences/%s.seq");
128 assert_eq!(result, std::path::PathBuf::from("sequences/ABCDEFghijklmnop.seq"));
129 }
130
131 #[test]
132 fn test_sanitize_relative_path() {
133 // Rejects traversal
134 assert!(ReadonlyRefgetStore::sanitize_relative_path("../etc/passwd").is_err());
135 assert!(ReadonlyRefgetStore::sanitize_relative_path("foo/../bar").is_err());
136 assert!(ReadonlyRefgetStore::sanitize_relative_path("foo/../../bar").is_err());
137 assert!(ReadonlyRefgetStore::sanitize_relative_path("..").is_err());
138
139 // Rejects absolute
140 assert!(ReadonlyRefgetStore::sanitize_relative_path("/etc/passwd").is_err());
141 assert!(ReadonlyRefgetStore::sanitize_relative_path("\\windows\\system32").is_err());
142
143 // Accepts valid
144 assert!(ReadonlyRefgetStore::sanitize_relative_path("sequences/ab/abc123.seq").is_ok());
145 assert!(ReadonlyRefgetStore::sanitize_relative_path("collections/xyz.rgsi").is_ok());
146 assert!(ReadonlyRefgetStore::sanitize_relative_path("rgstore.json").is_ok());
147 assert!(ReadonlyRefgetStore::sanitize_relative_path("sequences/%s2/%s.seq").is_ok());
148 }
149
150 #[test]
151 fn test_mode_basics() {
152 let mut store = RefgetStore::in_memory();
153
154 assert_eq!(store.mode, StorageMode::Encoded);
155
156 store.disable_encoding();
157 assert_eq!(store.mode, StorageMode::Raw);
158 store.enable_encoding().unwrap();
159 assert_eq!(store.mode, StorageMode::Encoded);
160
161 store.set_encoding_mode(StorageMode::Raw).unwrap();
162 assert_eq!(store.mode, StorageMode::Raw);
163 store.set_encoding_mode(StorageMode::Encoded).unwrap();
164 assert_eq!(store.mode, StorageMode::Encoded);
165 }
166}
167
168// Re-export public types from submodules
169pub use self::readonly::{PendingChanges, ReadonlyRefgetStore};
170pub use self::readonly::{CompactOptions, CompactReport};
171pub use self::core::RefgetStore;
172pub use self::alias::{AliasKind, AliasManager};
173#[cfg(feature = "filesystem")]
174pub use self::export::{ExportOptions, ExportSelection, ExportSummary, Molecule};
175pub use self::label::{LabelError, LabelTemplate};
176pub use self::atomic::is_transient_store_file;
177pub use self::lock::{LockInfo, LockOptions, StoreLock, force_unlock, lock_status};
178pub use self::fhr_metadata::{
179 FhrMetadata, FhrAuthor, FhrIdentifier, FhrTaxon, FhrVitalStats,
180 // Disk I/O helpers used by persistence and externally
181 load_sidecars, write_sidecars, write_sidecar, remove_sidecar, sidecar_path, load_from_json,
182};
183pub use self::verify::{
184 AlphabetVerifyCounts, VerifyFailure, VerifyFailureKind, VerifyOptions, VerifyReport,
185};
186
187use serde::{Deserialize, Serialize};
188use std::io::{BufReader, Read};
189// `BufRead` is only used by the filesystem-only FASTA import path (via `super::*`).
190#[cfg(feature = "filesystem")]
191#[allow(unused_imports)]
192use std::io::BufRead;
193
194pub(crate) use crate::hashkeyable::DigestKey;
195use crate::digest::SequenceCollectionMetadata;
196
197
198// =========================================================================
199// Shared constants
200// =========================================================================
201
202pub(crate) const DEFAULT_SEQDATA_PATH_TEMPLATE: &str = "sequences/%s2/%s.seq";
203
204/// zstd compression level used by [`StorageMode::Zstd`] records. High enough to
205/// wring out the internal repeat structure of satellite/segmental-dup/acrocentric
206/// novel content that 2-bit packing leaves on the table; the records are small
207/// (CDC chunks), so encode cost is negligible against a whole-genome build.
208pub(crate) const ZSTD_STORAGE_LEVEL: i32 = 19;
209
210// =========================================================================
211// Shared types used across multiple submodules
212// =========================================================================
213
214/// Paginated result container matching the seqcol spec response format.
215#[derive(Debug, Clone, Serialize, Deserialize)]
216pub struct PagedResult<T> {
217 pub results: Vec<T>,
218 pub pagination: Pagination,
219}
220
221#[derive(Debug, Clone, Serialize, Deserialize)]
222pub struct Pagination {
223 pub page: usize,
224 pub page_size: usize,
225 pub total: usize,
226}
227
228/// Enum storing whether sequences will be stored in Raw, Encoded, or Zstd form.
229///
230/// - `Raw`: one ASCII byte per residue. Byte offsets map 1:1 to base positions,
231/// so partial byte-window reads are possible.
232/// - `Encoded`: 2/3-bit packed to the alphabet's bits-per-symbol. Byte offsets
233/// map to base positions via the packing, so partial byte-window reads work.
234/// - `Zstd`: the whole ASCII record body compressed with zstd. There is no
235/// base->byte mapping into a compressed frame, so reads decompress the whole
236/// record once and slice `[start, end)` from the ASCII. Intended for
237/// digest-addressed novel/unplaced content whose records are small (CDC
238/// chunks, <=256 KiB), where a whole-frame decompress is microseconds. See
239/// `refgenie/panget_novel_unplaced_sequence_plan_v1.md` and
240/// `refgenie/zstd_block_sequences_project_idea.md`.
241#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq)]
242pub enum StorageMode {
243 Raw,
244 Encoded,
245 Zstd,
246}
247
248/// Store-level physical layout of sequence bytes. A sibling axis to
249/// [`StorageMode`] (encoding): all four mode x layout combinations are legal.
250///
251/// Store-level, not per-sequence, because a pack offset is only meaningful
252/// relative to a shared pack file — unlike encoding, which is computable per
253/// sequence. One store is uniformly packed or uniformly standalone.
254#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Default)]
255#[serde(rename_all = "lowercase")]
256pub enum Layout {
257 /// One `.seq` file per digest via the path template (the default).
258 #[default]
259 Standalone,
260 /// Sequences concatenated into sealed, size-capped pack files under
261 /// `packs/`, resolved via the `sequences.pack.idx` sidecar.
262 Packed,
263}
264
265#[derive(Debug, Clone, PartialEq, Eq)]
266pub struct RetrievedSequence {
267 pub sequence: String,
268 pub chrom_name: String,
269 pub start: u32,
270 pub end: u32,
271}
272
273/// Options for importing a FASTA file into a RefgetStore.
274///
275/// ## Single-knob parallelism model
276///
277/// `jobs` is the number of input FASTA files imported concurrently. `0` = auto
278/// (`std::thread::available_parallelism`). `1` = serial. It has no effect with a
279/// single input file (each file is processed by the basic read->digest->encode
280/// pipeline either way).
281///
282/// ## Two independent alias indexes
283///
284/// A store keeps *two* separate alias indexes, and these options feed exactly
285/// one each:
286///
287/// - `namespaces` feeds only the **sequence** alias index. It is a *parsing*
288/// directive: it lists which `ns:value` tokens to harvest out of each FASTA
289/// header and register per sequence.
290/// - `collection_alias` feeds only the **collection** alias index. It is an
291/// *assertion* by the caller naming the collection as a whole, because a FASTA
292/// says what each sequence is called but never what the assembly is called.
293///
294/// They are deliberately decoupled: setting `namespaces` never names the
295/// collection, and setting `collection_alias` never registers a sequence alias.
296#[derive(Clone, Copy)]
297pub struct FastaImportOptions<'a> {
298 pub(crate) force: bool,
299 pub(crate) namespaces: &'a [&'a str],
300 /// Number of input FASTA files imported concurrently. Each file gets its own
301 /// decoder so gzip decompression is parallelized across files. `0` = auto
302 /// (`std::thread::available_parallelism`), `1` = serial. No effect with a
303 /// single input file.
304 pub(crate) jobs: usize,
305 /// Optional `(namespace, alias)` under which the imported collection is
306 /// registered in the **collection** alias index (e.g. `("ucsc", "hg38")`).
307 ///
308 /// Independent of `namespaces`, which only controls per-sequence FASTA
309 /// header parsing and never names the collection. Rejected with an error
310 /// when more than one FASTA file is imported in a single call, since one
311 /// alias cannot name N collections. When unset, nothing is registered and
312 /// nothing is derived from the filename.
313 pub(crate) collection_alias: Option<(&'a str, &'a str)>,
314 /// Pre-flight ceiling on the number of `.seq` files a STANDALONE store may
315 /// hold after this import. Checked before any bytes are written; a store
316 /// that would exceed it errors, pointing the caller at the packed layout.
317 /// Packed stores bypass the gate; `force` does not. Default 500,000.
318 pub(crate) standalone_file_limit: usize,
319}
320
321impl<'a> Default for FastaImportOptions<'a> {
322 fn default() -> Self {
323 Self {
324 force: false,
325 namespaces: &[],
326 jobs: 0,
327 collection_alias: None,
328 standalone_file_limit: 500_000,
329 }
330 }
331}
332
333impl<'a> FastaImportOptions<'a> {
334 #[must_use]
335 pub fn new() -> Self {
336 Self::default()
337 }
338
339 #[must_use]
340 pub fn force(mut self, yes: bool) -> Self {
341 self.force = yes;
342 self
343 }
344
345 #[must_use]
346 pub fn namespaces(mut self, ns: &'a [&'a str]) -> Self {
347 self.namespaces = ns;
348 self
349 }
350
351 /// Set the number of input FASTA files imported concurrently.
352 /// `0` (the default) means auto via `std::thread::available_parallelism`;
353 /// `1` means serial. No effect with a single input file.
354 #[must_use]
355 pub fn jobs(mut self, n: usize) -> Self {
356 self.jobs = n;
357 self
358 }
359
360 /// Register the imported collection in the **collection** alias index under
361 /// `namespace:alias` (e.g. `.collection_alias("ucsc", "hg38")`).
362 ///
363 /// This is an explicit assertion by the caller — nothing in a FASTA file
364 /// names the assembly. It is independent of [`Self::namespaces`], which only
365 /// harvests per-sequence aliases from headers.
366 ///
367 /// Only valid when importing a single FASTA file; importing multiple files
368 /// with this set returns an error, because one alias cannot name N
369 /// collections. For the multi-file case, import without this option and call
370 /// `add_collection_alias` per returned collection (results come back in
371 /// input order).
372 ///
373 /// If the alias already resolves to a *different* collection digest, the
374 /// import errors rather than silently remapping it, unless
375 /// [`Self::force`] is set. Re-registering the same digest is a no-op.
376 #[must_use]
377 pub fn collection_alias(mut self, namespace: &'a str, alias: &'a str) -> Self {
378 self.collection_alias = Some((namespace, alias));
379 self
380 }
381
382 /// Set the pre-flight ceiling on `.seq` file count for STANDALONE imports.
383 /// Packed stores bypass this gate; `force` does not. 0 is not special: to
384 /// lift the limit, pass a large number.
385 #[must_use]
386 pub fn standalone_file_limit(mut self, limit: usize) -> Self {
387 self.standalone_file_limit = limit;
388 self
389 }
390}
391
392/// Metadata for the entire store.
393/// This is used to serialize metadata to `rgstore.json`, which can be loaded by the application.
394#[derive(Serialize, Deserialize, Debug)]
395pub(crate) struct StoreMetadata {
396 /// Version of the metadata format
397 pub(crate) version: u32,
398 /// Template for sequence file paths
399 pub(crate) seqdata_path_template: String,
400 /// Template for collection file paths
401 pub(crate) collections_path_template: String,
402 /// Path to the sequence metadata index file
403 pub(crate) sequence_index: String,
404 /// Path to the collection metadata index file (NEW)
405 #[serde(default)]
406 pub(crate) collection_index: Option<String>,
407 /// Storage mode (Raw or Encoded)
408 pub(crate) mode: StorageMode,
409 /// Physical layout of sequence bytes (Standalone or Packed). Old manifests
410 /// without this field deserialize as `Standalone` — the entire migration
411 /// story.
412 #[serde(default)]
413 pub(crate) layout: Layout,
414 /// Creation timestamp
415 pub(crate) created_at: String,
416 /// Whether ancillary digests are computed and stored
417 #[serde(default = "default_true")]
418 pub(crate) ancillary_digests: bool,
419 /// Whether the on-disk attribute index is maintained
420 #[serde(default)]
421 pub(crate) attribute_index: bool,
422 /// Available sequence alias namespaces (for remote discovery)
423 #[serde(default, skip_serializing_if = "Vec::is_empty")]
424 pub(crate) sequence_alias_namespaces: Vec<String>,
425 /// Available collection alias namespaces (for remote discovery)
426 #[serde(default, skip_serializing_if = "Vec::is_empty")]
427 pub(crate) collection_alias_namespaces: Vec<String>,
428 /// Last-modified timestamp (RFC 3339). Updated on every write_index_files().
429 #[serde(default, skip_serializing_if = "Option::is_none")]
430 pub(crate) modified: Option<String>,
431 /// SHA256 digest of collections.rgci
432 #[serde(default, skip_serializing_if = "Option::is_none")]
433 pub(crate) collections_digest: Option<String>,
434 /// SHA256 digest of sequences.rgsi
435 #[serde(default, skip_serializing_if = "Option::is_none")]
436 pub(crate) sequences_digest: Option<String>,
437 /// SHA256 digest of combined alias data
438 #[serde(default, skip_serializing_if = "Option::is_none")]
439 pub(crate) aliases_digest: Option<String>,
440 /// SHA256 digest of combined FHR sidecar data
441 #[serde(default, skip_serializing_if = "Option::is_none")]
442 pub(crate) fhr_digest: Option<String>,
443 /// Logical sequence-data size in bytes (sum of length x storage-mode encoding),
444 /// computed once at index-write time. Lets a consumer read the store's size from
445 /// the manifest without loading the sequence index. Excludes index/sidecar
446 /// overhead. `None` for manifests written before this field existed.
447 #[serde(default, skip_serializing_if = "Option::is_none")]
448 pub(crate) logical_sequence_bytes: Option<u64>,
449}
450
451pub(crate) fn default_true() -> bool {
452 true
453}
454
455/// Statistics for a RefgetStore.
456///
457/// These are a snapshot of the store's CURRENT RAM residency, not a record of
458/// what a given import run did. For per-run ingest counts, use [`ImportReport`]
459/// returned by `add_sequence_collections_from_fastas`.
460#[derive(Debug, Clone)]
461pub struct StoreStats {
462 /// Total number of sequences (loaded or not)
463 pub n_sequences: usize,
464 /// Number of sequences whose bytes are currently held in RAM (loaded).
465 /// Structurally always 0 for a disk-backed store: importing drops each
466 /// sequence's bytes after handing them off to be written (see
467 /// `add_sequence_record_deferred_write`). Only an on-demand fetch loads
468 /// them again.
469 pub n_sequences_in_memory: usize,
470 /// Total number of collections (loaded or not)
471 pub n_collections: usize,
472 /// Number of collections whose member list is currently held in RAM
473 /// (loaded). Collections finalized by this process are loaded; collections
474 /// read from `collections.rgci` are not. This is a
475 /// residency gauge, NOT a count of collections added by this run — it
476 /// resets on process start and also counts collections merely touched by
477 /// a read.
478 pub n_collections_in_memory: usize,
479 /// Storage mode (Raw or Encoded)
480 pub storage_mode: String,
481 /// Logical size in bytes of all sequence payloads (length x storage-mode
482 /// encoding). Excludes index/sidecar/manifest overhead. For the exact full
483 /// on-disk footprint use `ReadonlyRefgetStore::actual_disk_usage()`.
484 pub logical_sequence_bytes: u64,
485 /// Dead (unreferenced) bytes inside pack files for a PACKED store:
486 /// `sum(pack sizes) - sum(live sidecar lengths)`. `None` for a standalone
487 /// store, where per-sequence `.seq` files are unlinked eagerly.
488 pub packed_dead_bytes: Option<u64>,
489}
490
491/// Result of importing one or more FASTA files.
492///
493/// Unlike [`StoreStats`] (a RAM-residency gauge), these are genuine per-run
494/// counters describing what this import actually did.
495///
496/// `n_sequences_written + n_sequences_deduped` equals the total number of
497/// sequence records seen across all *processed* files. Files short-circuited
498/// as already-present collections (before their FASTA is ever opened)
499/// contribute nothing to either counter.
500#[derive(Debug, Clone)]
501pub struct ImportReport {
502 /// Per-file results in input order: `(metadata, was_new)`.
503 pub collections: Vec<(SequenceCollectionMetadata, bool)>,
504 /// Sequences whose bytes were written this run (i.e. genuinely new
505 /// content). For in-memory stores, sequences newly
506 /// inserted into the in-memory map.
507 pub n_sequences_written: usize,
508 /// Sequences already present (by content digest), so no bytes were written.
509 pub n_sequences_deduped: usize,
510 /// Number of collections newly added by this run.
511 pub n_collections_new: usize,
512}
513
514/// Format bytes into human-readable size (KB, MB, GB, etc.)
515pub(crate) fn format_bytes(bytes: usize) -> String {
516 const UNITS: &[&str] = &["B", "KB", "MB", "GB", "TB"];
517 let mut size = bytes as f64;
518 let mut unit_idx = 0;
519
520 while size >= 1024.0 && unit_idx < UNITS.len() - 1 {
521 size /= 1024.0;
522 unit_idx += 1;
523 }
524
525 if unit_idx == 0 {
526 format!("{} {}", bytes, UNITS[0])
527 } else {
528 format!("{:.2} {}", size, UNITS[unit_idx])
529 }
530}
531
532// =========================================================================
533// Sidecar sync types
534// =========================================================================
535
536/// Conflict resolution strategy for sidecar pull operations.
537#[derive(Debug, Clone, Copy, PartialEq, Eq)]
538pub enum SyncStrategy {
539 /// Skip fetch if local file exists (default). Local wins.
540 KeepOurs,
541 /// Always fetch from remote, overwriting local. Remote wins.
542 KeepTheirs,
543 /// Report what would change without fetching. Returns diff info.
544 Notify,
545}
546
547/// Result of a sidecar pull operation.
548#[derive(Debug, Default)]
549pub struct PullResult {
550 /// Successfully fetched from remote
551 pub pulled: usize,
552 /// Skipped (local exists, KeepOurs)
553 pub skipped: usize,
554 /// Remote 404 (no sidecar exists)
555 pub not_found: usize,
556 /// For Notify: paths that differ between local and remote
557 pub conflicts: Vec<String>,
558}
559
560/// Available alias namespaces advertised by a store's manifest.
561#[derive(Debug)]
562pub struct AvailableAliases<'a> {
563 pub sequences: &'a [String],
564 pub collections: &'a [String],
565}
566
567/// Iterator over BED file regions yielding substrings from a store.
568// Constructed only by the filesystem BED-streaming path; fields go unread on
569// the WASM (no-filesystem) build.
570#[cfg_attr(not(feature = "filesystem"), allow(dead_code))]
571pub struct SubstringsFromRegions<'a, K>
572where
573 K: AsRef<[u8]>,
574{
575 pub(crate) store: &'a ReadonlyRefgetStore,
576 pub(crate) reader: BufReader<Box<dyn Read>>,
577 pub(crate) collection_digest: K,
578 pub(crate) previous_parsed_chr: String,
579 pub(crate) current_seq_digest: String,
580 pub(crate) line_num: usize,
581}
582
583/// Iterator over in-memory region vectors yielding substrings from a store.
584///
585/// Unlike `SubstringsFromRegions`, this has no filesystem dependency: it
586/// iterates caller-supplied parallel `chroms`/`starts`/`ends` vectors.
587// Constructed only by the filesystem-gated `export` module today; fields go
588// unread on the WASM (no-filesystem) build.
589#[cfg_attr(not(feature = "filesystem"), allow(dead_code))]
590pub struct SubstringsFromRegionVectors<'a, K>
591where
592 K: AsRef<[u8]>,
593{
594 pub(crate) store: &'a ReadonlyRefgetStore,
595 pub(crate) collection_digest: K,
596 pub(crate) chroms: Vec<String>,
597 pub(crate) starts: Vec<u32>,
598 pub(crate) ends: Vec<u32>,
599 pub(crate) index: usize,
600 pub(crate) previous_parsed_chr: String,
601 pub(crate) current_seq_digest: String,
602}