Skip to main content

SubtitleDecoder

Trait SubtitleDecoder 

Source
pub trait SubtitleDecoder {
    type Adapter: SubtitleAdapter;
    type Buffer: AsRef<[u8]>;
    type Error;

    // Required methods
    fn send_packet(
        &mut self,
        packet: &SubtitlePacket<<Self::Adapter as SubtitleAdapter>::PacketExtra, Self::Buffer>,
    ) -> Result<Sent, Self::Error>;
    fn receive_frame(
        &mut self,
        dst: &mut SubtitleFrame<<Self::Adapter as SubtitleAdapter>::FrameExtra, Self::Buffer>,
    ) -> Result<Received, Self::Error>;
    fn send_eof(&mut self) -> Result<Sent, Self::Error>;
    fn flush(&mut self) -> Result<(), Self::Error>;
}
Expand description

Push-style subtitle decoder. (No pull-style subtitle decoders exist in the wild — subtitle streams are linear and small.)

Required Associated Types§

Source

type Adapter: SubtitleAdapter

Backend vocabulary.

Source

type Buffer: AsRef<[u8]>

Buffer type.

Source

type Error

Decoder-specific error.

Required Methods§

Source

fn send_packet( &mut self, packet: &SubtitlePacket<<Self::Adapter as SubtitleAdapter>::PacketExtra, Self::Buffer>, ) -> Result<Sent, Self::Error>

Submits a compressed subtitle packet. See VideoStreamDecoder::send_packet.

Source

fn receive_frame( &mut self, dst: &mut SubtitleFrame<<Self::Adapter as SubtitleAdapter>::FrameExtra, Self::Buffer>, ) -> Result<Received, Self::Error>

Drains a decoded subtitle frame into dst.

A backend whose underlying API produces a cue inline with the packet still answers all three: Received::NeedsInput until a packet has produced one, and Received::Ended once send_eof has been signalled and no cue is held. A subtitle decoder with no tail to drain is still a session with an end, and saying so is what lets a generic drain loop stop.

Source

fn send_eof(&mut self) -> Result<Sent, Self::Error>

Signals EOF.

Source

fn flush(&mut self) -> Result<(), Self::Error>

Flushes internal state.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§