1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! Crate-internal positioned-read helper.
//!
//! Provides a single cursorless byte-window read over a shared `&File`.
//!
//! ## Platform strategy
//!
//! On Unix the read is implemented via `pread` (`FileExt::read_exact_at`): the
//! call takes an explicit byte offset and does NOT advance the file cursor, so it
//! is safe to call concurrently on a shared `&File` (the basis for the cached
//! `Arc<File>` in the sequence store and the single `Arc<File>` in the pread
//! transcript backend).
//!
//! On non-Unix platforms there is no `pread` equivalent in stable std, so the
//! fallback clones the handle via `try_clone()` (giving it an **independent**
//! cursor), seeks to `byte_start`, and calls `read_exact`. Cloning is slightly
//! more expensive than `pread` but avoids cursor races on a shared handle.
//!
//! ## Why this module is ungated
//!
//! The sequence-store caller in `store/readonly.rs` is declared without a feature
//! gate and compiles in ALL configurations (including `--no-default-features`).
//! Gating this module behind `filesystem` would break that build, so the module
//! must be ungated. The transcript-backend caller in `transcripts/mmap.rs` IS
//! gated behind `filesystem`, so the function is always reachable from at least
//! one call site regardless of feature combination.
use File;
use Result;
/// Read exactly `len` bytes starting at byte offset `byte_start` from `file`.
///
/// The read is cursorless on Unix (`pread`) and therefore safe to call
/// concurrently on a shared `&File`. On non-Unix a cloned handle is used so
/// that concurrent readers do not race on a single seek position.
pub