vobsub 0.2.3

Decode DVD VobSub-format subtitles (*.sub/*.idx files)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Miscellaneous utilities.

use std::fmt;

/// Wrapper to force a `&[u8]` to display as nicely-formatted hexadecimal
/// bytes with only the the first line or so of bytes shown.
pub struct BytesFormatter<'a>(pub &'a [u8]);

impl<'a> fmt::Debug for BytesFormatter<'a> {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        let BytesFormatter(bytes) = *self;
        for byte in bytes.iter().take(16) {
            write!(f, "{:02x} ", byte)?;
        }
        write!(f, "({} bytes)", bytes.len())?;
        Ok(())
    }
}