Skip to main content

rskit_media/chunking/strategy/
chunk_strategy.rs

1//! The chunk strategy trait.
2
3use std::time::Duration;
4
5use rskit_errors::AppResult;
6
7use crate::chunking::types::{ChunkBoundary, ChunkedOperation};
8use crate::probe::MediaMetadata;
9
10/// Strategy for splitting media into processable chunks.
11///
12/// Implementations determine where to place chunk boundaries based on the media metadata
13/// and operation requirements.
14pub trait ChunkStrategy: Send + Sync {
15    /// Human-readable name of this strategy.
16    fn name(&self) -> &str;
17
18    /// Plan chunk boundaries for the given media.
19    ///
20    /// Returns a complete [`ChunkedOperation`] with ordered chunk plans and reassembly instructions.
21    fn plan(
22        &self,
23        metadata: &MediaMetadata,
24        boundaries: &[ChunkBoundary],
25    ) -> AppResult<ChunkedOperation>;
26
27    /// Minimum duration below which chunking is not worthwhile.
28    /// Returns `None` if this strategy always chunks.
29    fn min_duration(&self) -> Option<Duration> {
30        Some(Duration::from_secs(600)) // 10 minutes default
31    }
32}