pub struct SegmentWriter {
pub torn_bytes_at_start: u64,
/* private fields */
}Fields§
§torn_bytes_at_start: u64How many bytes of torn tail were cut off at startup.
Implementations§
Source§impl SegmentWriter
impl SegmentWriter
pub fn open(cfg: SegmentConfig) -> Result<SegmentWriter>
Sourcepub fn append(&mut self, rec: &Record) -> Result<Option<Sealed>>
pub fn append(&mut self, rec: &Record) -> Result<Option<Sealed>>
Adds a record. If it is time to close the current segment, closes it and returns its seal.
After a start with an empty journal, the first WARMUP records are
buffered in memory while the median cannot be trusted yet: opening a
segment on a stray validation from a foreign network would slice the
archive in the wrong place. If that happens anyway, the segment
re-slices itself (see the stale condition below), and completeness
responsibility does not mix up lineages (see Lineage).
Sourcepub fn current(&self) -> Option<(u32, u64)>
pub fn current(&self) -> Option<(u32, u64)>
Nominal start of the open segment and the number of records in it.
Sourcepub fn network_ledger(&self) -> Option<u32>
pub fn network_ledger(&self) -> Option<u32>
The network’s current ledger, from the median of recent records.
Sourcepub fn is_out_of_window(&self, ledger: u32) -> bool
pub fn is_out_of_window(&self, ledger: u32) -> bool
The record is far from the current ledger: a foreign network or very late.
Sourcepub fn journal_bytes(&self) -> u64
pub fn journal_bytes(&self) -> u64
Size of the open segment’s journal, including what has not been flushed.
Sourcepub fn last_ledger(&self) -> Option<u32>
pub fn last_ledger(&self) -> Option<u32>
The highest ledger index among records in the open segment.