ff_format/time/mod.rs
1//! Time primitives for video/audio processing.
2//!
3//! This module provides [`Rational`] for representing fractions (like time bases
4//! and frame rates) and [`Timestamp`] for representing media timestamps with
5//! their associated time base.
6//!
7//! # Examples
8//!
9//! ```
10//! use ff_format::{Rational, Timestamp};
11//! use std::time::Duration;
12//!
13//! // Create a rational number (e.g., 1/90000 time base)
14//! let time_base = Rational::new(1, 90000);
15//! assert_eq!(time_base.as_f64(), 1.0 / 90000.0);
16//!
17//! // Create a timestamp at 1 second (90000 * 1/90000)
18//! let ts = Timestamp::new(90000, time_base);
19//! assert!((ts.as_secs_f64() - 1.0).abs() < 0.0001);
20//!
21//! // Convert to Duration
22//! let duration = ts.as_duration();
23//! assert_eq!(duration.as_secs(), 1);
24//! ```
25
26mod rational;
27mod timestamp;
28
29pub use rational::Rational;
30pub use timestamp::Timestamp;