Skip to main content

CiDataDevice

Trait CiDataDevice 

Source
pub trait CiDataDevice {
    // Required methods
    fn write(&mut self, ts: &[u8]) -> Result<()>;
    fn read(&mut self, buf: &mut [u8]) -> Result<usize>;
    fn poll(&mut self, timeout: Duration) -> Result<bool>;
}
Expand description

The TS data-plane device of a separate-CI module (/dev/dvb/adapterN/ciM).

The host pushes scrambled TS in with write and pulls the descrambled TS out with read. Implementations: MockCiDataDevice (in-memory, for tests + differential harness) and, with the linux feature, a device over /dev/dvb/.../ci.

Required Methods§

Source

fn write(&mut self, ts: &[u8]) -> Result<()>

Write scrambled TS to the module. ts must be a whole number of TS_PACKET_LEN-byte packets.

An implementation must never leave a packet half written. When the device cannot take all of ts (its buffer is full) it returns an io::ErrorKind::WouldBlock error carrying a PartialWrite — read it with partial_write_progress — whose written is the number of whole-packet bytes the device did accept, so the caller can resume after them (see CaDescrambler::feed_ts, which drains the device and retries the unsent tail).

Source

fn read(&mut self, buf: &mut [u8]) -> Result<usize>

Read descrambled TS into buf (sized to a multiple of TS_PACKET_LEN); returns the byte count. Ok(0) means none available (non-blocking).

Source

fn poll(&mut self, timeout: Duration) -> Result<bool>

Wait up to timeout for descrambled TS to become readable; Ok(true) if readable.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl CiDataDevice for LinuxCiDataDevice

Available on Linux and crate feature linux only.
Source§

impl CiDataDevice for MockCiDataDevice