Module builder

Source
Expand description

Builder pattern for configuring and constructing decoders.

This module provides a flexible builder API for creating decoders with custom settings. The builder allows configuring format hints, seeking behavior, byte length and other parameters that affect decoder behavior.

§Examples

use std::fs::File;
use rodio::Decoder;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let file = File::open("audio.mp3")?;
    let len = file.metadata()?.len();

    Decoder::builder()
        .with_data(file)
        .with_byte_len(len)      // Enable seeking and duration calculation
        .with_hint("mp3")        // Optional format hint
        .with_gapless(true)      // Enable gapless playback
        .build()?;

    // Use the decoder...
    Ok(())
}

§Settings

The following settings can be configured:

  • byte_len - Total length of the input data in bytes
  • hint - Format hint like “mp3”, “wav”, etc
  • mime_type - MIME type hint for container formats
  • seekable - Whether seeking operations are enabled
  • gapless - Enable gapless playback
  • coarse_seek - Use faster but less precise seeking

Structs§

DecoderBuilder
Builder for configuring and creating a decoder.
Settings
Audio decoder configuration settings. Support for these settings depends on the underlying decoder implementation. Currently, settings are only used by the Symphonia decoder.