Skip to main content

SegmentWriter

Struct SegmentWriter 

Source
pub struct SegmentWriter { /* private fields */ }
Available on crate feature std only.
Expand description

The write handle for a Trunk’s segments + parts ring group. Obtained via Trunk::segment_writer, independently of TrunkWriter (via Trunk::writer) — see One writer per ring group for why this split exists, why note_segment_start/set_time_anchor are grouped here rather than on TrunkWriter, and what is (and is not) guaranteed about ordering relative to the sample/event rings.

Like TrunkWriter, every method here either never blocks (ordinary eviction, exactly the sample rings’ non-blocking-producer principle) or blocks only in the one documented ArchiveOverrun::StallIngest case — see SegmentWriter::publish_segment.

Implementations§

Source§

impl SegmentWriter

Source

pub fn publish_segment(&self, entry: SegmentEntry)

Publish one finished segment, in playlist order.

Never blocks and never rejects for every non-pinning SegmentCursor and for every pinning cursor using ArchiveOverrun::Gap (the default) or ArchiveOverrun::Terminate — a full segment log evicts its oldest entry exactly like TrunkWriter::publish’s sample rings. The one exception, by design, is a pinning cursor using ArchiveOverrun::StallIngest that has not yet consumed the entry about to be evicted: this call blocks until that cursor consumes further (or is dropped) — see The DVR contradiction. The block is a std::sync::Condvar::wait, which releases the shared Mutex while parked, so TrunkWriter::publish and every cursor’s poll on other data remain free to proceed even while this call is stalled.

Does not touch the live-part log — see The live-part log for why a segment closing deliberately leaves that segment’s parts exactly as addressable as they were the instant before. Wakes any Trunk::listen registration once this call is about to return (bare-_HLS_msn blocking-reload’s condition), even on the StallIngest path — a waiter is woken only after the entry has actually landed, never merely because a pin released.

Source

pub fn publish_part(&self, entry: PartEntry)

Publish one live part of the segment currently being written — see The live-part log.

Never blocks and never rejects: a full part log evicts its oldest entry exactly like every other ring in this module — the same non-blocking-producer principle as TrunkWriter::publish/ SegmentWriter::publish_segment’s ordinary (non-StallIngest) path. Wakes any Trunk::listen registration once this part has actually landed (RFC 8216bis blocking-reload’s part-availability condition).

Source

pub fn note_segment_start(&self, segment_number: u32, start: MediaTime)

Report that segment segment_number starts at start on this trunk’s 90 kHz absolute clock — the boundary an EventAnchor::Segment (an emsg v0’s presentation_time_delta) needs before it can resolve. Called by whoever owns segmentation — the entity the spec’s B1 fix names explicitly: “it cannot be finalised until the segmenter owns a boundary.” Lives here, not on TrunkWriter, for exactly that reason: only the segmenter can honestly report it. This does not append to the event ring — it resolves an already-published EventAnchor::Segment entry in place, so grouping it with SegmentWriter::publish_segment does not create a second appender for TrunkWriter::publish_event’s ring; see One writer per ring group.

Source

pub fn set_time_anchor(&self, anchor: TimeAnchor)

Give the event log a wall-clock↔media-clock mapping. Resolves every currently-pending EventAnchor::Utc entry immediately, and every future one at publish time, until a later call replaces it. Grouped with SegmentWriter::note_segment_start rather than split onto TrunkWriter — see One writer per ring group for why, and the same in-place-resolution reasoning: this is not an append to the event ring either.

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