Skip to main content

resolve_sync_pairing

Function resolve_sync_pairing 

Source
pub fn resolve_sync_pairing(
    request: &SyncPairingRequest,
) -> Result<SyncMode, SubXError>
Expand description

Decide whether a sync invocation is a single pair or a batch, auto-pairing a lone video or subtitle with its sibling on disk.

Algorithm (locked by the timeline-sync capability spec):

  1. Any batch trigger (batch != Off, non-empty input_paths, or an extension-less positional path) selects SyncMode::Batch, with the handler’s paths ordered batch directory → -i paths → positionals and defaulting to ["."] when empty.
  2. A lone positional path is classified by its lower-cased extension and probed for a <stem>.<ext> sibling over the declared extension lists.
  3. Two positional paths are classified by extension without probing.
  4. Otherwise the explicit video/subtitle fields are used.
  5. In manual mode a resolved subtitle with no video yields SyncMode::Single with an empty PathBuf video (“no video required” sentinel).
  6. Anything else returns SubXError::InvalidSyncConfiguration.