smptera-format-identifiers-rust 0.3.0

Constants for Format Identifiers defined by the SMPTE Registration Authority
Documentation

Format Identifier value on record with the SMPTE Registration Authority for use in MPEG Transport Stream data.

(This create is automatically generated from a mirror of the SMPTE-RA data by code in the smptera-format-identifiers-rust project.)

The simple wrapper type FormatIdentifier defines a constant for each format identifier in the SMPTE-RA data,

# use smptera_format_identifers_rust::FormatIdentifier;
use std::io::stdout;
println!("{:?}", FormatIdentifier::AC_3);
// prints: FormatIdentifier(FourCC{AC-3})

Usage

Create from a slice,

# use smptera_format_identifers_rust::FormatIdentifier;
let descriptor_data = b"\x05\x04CUEI";
let id = FormatIdentifier::from(&descriptor_data[2..6]);
assert_eq!(id, FormatIdentifier::CUEI);

Wrap an existing FourCC value,

# use smptera_format_identifers_rust::FormatIdentifier;
# use four_cc::FourCC;
let fcc = FourCC(*b"CUEI");
let id = FormatIdentifier(fcc);
assert_eq!(id, FormatIdentifier::CUEI);

Use provided constants in matches,

# use smptera_format_identifers_rust::FormatIdentifier;
# let descriptor_data = b"\x05\x04CUEI";
match FormatIdentifier::from(&descriptor_data[2..6]) {
FormatIdentifier::CUEI => println!("SCTE-35 suspected"),
FormatIdentifier::KLVA => println!("SMPTE RP 217-2001 KLV Packets?"),
other_id => println!("Some other kinda stuff: {:?}", other_id),
}

Write bytes values,

# use smptera_format_identifers_rust::FormatIdentifier;
# use std::io::{Cursor, Write};
let mut data = vec![];
let mut io = Cursor::new(data);

let id = &FormatIdentifier::ID3;
io.write(id.into())
.expect("write failed");

assert_eq!(io.into_inner(), [b'I', b'D', b'3', b' ']);