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
//! A descriptor for a contiguous run of records bytes that live in a segment
//! `.log` file, used by the zero-copy fetch path (Increment D).
//!
//! Instead of `pread`ing the records into an owned `Bytes` (the userspace copy
//! out of the page cache), the fetch read returns the `(file, offset, len)`
//! triple. The broker then `sendfile(2)`s that range straight from the page
//! cache to a plaintext socket — never bringing the bytes into userspace. The
//! `Arc<File>` pins the inode through the async send even if compaction or
//! truncation removes the segment from the log in the meantime (the open fd
//! keeps the inode alive on Unix).
//!
//! `FileRegion` is intentionally pure-`std` (`Arc<std::fs::File>` + integers) so
//! the protocol crate needs no new dependency and the same type can flow from
//! the log crate's `read_raw_desc` through `RecordsPayload::FileRegions` to the
//! broker's sendfile drainer.
use ;
/// A `[offset, offset+len)` byte range within a segment `.log` file that holds
/// one or more complete (or a clipped trailing) v2 record batches — byte-for-
/// byte the records-field bytes a fetch response would otherwise materialize.