Skip to main content

SectionStream

Struct SectionStream 

Source
pub struct SectionStream<R> { /* private fields */ }
Expand description

Async Stream of SectionEvents from a raw TS byte source.

Feed any tokio::io::AsyncRead byte source (file, TCP socket, UDP socket) and receive one SectionEvent per changed complete SI section.

Internally the adapter:

  1. Reads bytes from reader into a fixed-size buffer.
  2. Resyncs on the first 0x47 sync byte (via crate::resync::resync).
  3. Feeds each aligned 188-byte packet into the owned SiDemux.
  4. Yields events from the demux’s output queue before reading more.

§Owned events

SectionEvent already owns its section bytes via bytes::Bytes and is 'static, Clone, and Send + Sync. No additional wrapping is needed.

§Cancellation

Drop the stream. No internal tasks are spawned.

Implementations§

Source§

impl<R: AsyncRead + Unpin> SectionStream<R>

Source

pub fn new(reader: R) -> Self

Create a SectionStream with the default SiDemux configuration (all standard DVB/SI PIDs, PAT-follow enabled, version gating).

Source

pub fn with_builder(reader: R, builder: SiDemuxBuilder) -> Self

Create a SectionStream with a custom SiDemuxBuilder.

Source

pub fn with_demux(reader: R, demux: SiDemux) -> Self

Create a SectionStream with an already-constructed SiDemux.

Source

pub fn stats(&self) -> Stats

Access the underlying demux statistics.

Source

pub fn resync_stats(&self) -> ResyncStats

Access the resync statistics.

Source§

impl SectionStream<UdpReader>

UDP/multicast convenience constructor — enabled by the udp feature.

Source

pub async fn bind_multicast( bind_addr: SocketAddrV4, multicast_addr: Ipv4Addr, ) -> Result<Self>

Bind a UDP socket to bind_addr and join multicast_addr.

Typical DVB multicast delivery uses addresses like 239.0.0.1:5004. The returned SectionStream reads one UDP datagram per poll_next cycle from the socket (treated as a raw TS byte source).

§Errors

Returns a std::io::Error if binding or joining the multicast group fails.

Trait Implementations§

Source§

impl<R: AsyncRead + Unpin> Stream for SectionStream<R>

Source§

type Item = SectionEvent

Values yielded by the stream.
Source§

fn poll_next( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Option<Self::Item>>

Attempt to pull out the next value of this stream, registering the current task for wakeup if the value is not yet available, and returning None if the stream is exhausted. Read more
Source§

fn size_hint(&self) -> (usize, Option<usize>)

Returns the bounds on the remaining length of the stream. Read more

Auto Trait Implementations§

§

impl<R> Freeze for SectionStream<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for SectionStream<R>
where R: RefUnwindSafe,

§

impl<R> Send for SectionStream<R>
where R: Send,

§

impl<R> Sync for SectionStream<R>
where R: Sync,

§

impl<R> Unpin for SectionStream<R>
where R: Unpin,

§

impl<R> UnsafeUnpin for SectionStream<R>
where R: UnsafeUnpin,

§

impl<R> UnwindSafe for SectionStream<R>
where R: UnwindSafe,

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.