pub struct Timestamp(/* private fields */);Expand description
32-bits signed timestamp in milliseconds.
Implementations§
Source§impl Timestamp
impl Timestamp
Sourcepub fn value(self) -> i32
pub fn value(self) -> i32
Returns the value of this timestamp in milliseconds.
Examples found in repository?
examples/parse.rs (line 34)
11fn main() -> Result<(), MainError> {
12 let stdin = std::io::stdin();
13 let mut input = stdin.lock();
14 let mut buf = ReadBuf::new(vec![0; 1024]);
15 let mut decoder = FileDecoder::new();
16 let mut is_header_shown = false;
17
18 while !buf.stream_state().is_eos() {
19 track!(buf.fill(&mut input))?;
20 track!(decoder.decode_from_read_buf(&mut buf))?;
21 if let Some(h) = decoder.header() {
22 if !is_header_shown {
23 println!("[header]");
24 println!("has_audio = {}", h.has_audio);
25 println!("has_video = {}", h.has_video);
26 println!("");
27 is_header_shown = true;
28 }
29 }
30 if decoder.is_idle() {
31 let tag = track!(decoder.finish_decoding())?;
32 println!("[[tags]]");
33 println!("type = {:?}", tag_type(&tag));
34 println!("timestamp = {}", tag.timestamp().value());
35 println!("stream_id = {}", tag.stream_id().value());
36 println!("");
37 }
38 }
39
40 Ok(())
41}Sourcepub fn to_duration(self) -> Option<Duration>
pub fn to_duration(self) -> Option<Duration>
Converts Timestamp to Duration.
If the value of this timestamp is negative, it will return None.
Sourcepub fn from_duration(duration: Duration) -> Result<Self>
pub fn from_duration(duration: Duration) -> Result<Self>
Converts Duration to Timestamp.
§Errors
If the value of duration is too large (i.e., greater than i32::MAX),
it will return an ErrorKind::InvalidInput error.
Trait Implementations§
Source§impl Ord for Timestamp
impl Ord for Timestamp
Source§impl PartialOrd for Timestamp
impl PartialOrd for Timestamp
impl Copy for Timestamp
impl Eq for Timestamp
impl StructuralPartialEq for Timestamp
Auto Trait Implementations§
impl Freeze for Timestamp
impl RefUnwindSafe for Timestamp
impl Send for Timestamp
impl Sync for Timestamp
impl Unpin for Timestamp
impl UnwindSafe for Timestamp
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more