Struct swf_headers::SwfHeaders
[−]
[src]
pub struct SwfHeaders { // some fields omitted }
The primary struct, managing all the parsing and storage of SWF header information.
Methods
impl SwfHeaders
fn open<T: AsRef<Path>>(path: T) -> Result<(Self, DecodedSwf), Error>
Wraps over read_from(), taking a path and opening it for you.
Examples
use swf_headers::SwfHeaders; if let Ok((headers, decoded)) = SwfHeaders::open("example.swf") { // ... }
fn read_from(file: File) -> Result<(Self, DecodedSwf), Error>
Takes a SWF file and parses its headers, returning the header struct along with a readable DecodedSwf if you wish to continue parsing the file.
The vast bulk of SWF parsing happens in here. The code is documented, so you can read through the source if you want to understand how it all works.
Examples
use std::fs::File; use swf_headers::SwfHeaders; if let Ok(file) = File::open("example.swf") { let (headers, decoded) = SwfHeaders::read_from(file).unwrap(); // ... }
fn signature(&self) -> Signature
Returns the signature as an enum representing all valid values.
fn version(&self) -> u8
Returns the version number.
fn file_length(&self) -> u32
Returns the uncompressed total file length in bytes.
fn dimensions_twips(&self) -> (u32, u32)
Returns the dimensions in twips (the measurement unit flash uses, 1/20th of a pixel).
fn dimensions(&self) -> (u32, u32)
Returns the dimensions in pixels (converted from twips, sometimes losing accuracy).
fn frame_rate(&self) -> u16
Returns the frame rate (note: does not yet handle fractional framerates).
fn frame_count(&self) -> u16
Returns the frame count.