Skip to main content

SegmentWriter

Struct SegmentWriter 

Source
pub struct SegmentWriter {
    pub torn_bytes_at_start: u64,
    /* private fields */
}

Fields§

§torn_bytes_at_start: u64

How many bytes of torn tail were cut off at startup.

Implementations§

Source§

impl SegmentWriter

Source

pub fn open(cfg: SegmentConfig) -> Result<SegmentWriter>

Source

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).

Source

pub fn sync(&mut self) -> Result<()>

Flushes the journal to disk.

Source

pub fn current(&self) -> Option<(u32, u64)>

Nominal start of the open segment and the number of records in it.

Source

pub fn network_ledger(&self) -> Option<u32>

The network’s current ledger, from the median of recent records.

Source

pub fn is_out_of_window(&self, ledger: u32) -> bool

The record is far from the current ledger: a foreign network or very late.

Source

pub fn journal_bytes(&self) -> u64

Size of the open segment’s journal, including what has not been flushed.

Source

pub fn last_ledger(&self) -> Option<u32>

The highest ledger index among records in the open segment.

Trait Implementations§

Source§

impl Debug for SegmentWriter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.