Struct SwfHeaders

Source
pub struct SwfHeaders { /* private fields */ }
Expand description

The primary struct, managing all the parsing and storage of SWF header information.

Implementations§

Source§

impl SwfHeaders

Source

pub 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") {
    // ...
}
Source

pub 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();
    // ...
}
Source

pub fn signature(&self) -> Signature

Returns the signature as an enum representing all valid values.

Source

pub fn version(&self) -> u8

Returns the version number.

Source

pub fn file_length(&self) -> u32

Returns the uncompressed total file length in bytes.

Source

pub fn dimensions_twips(&self) -> (u32, u32)

Returns the dimensions in twips (the measurement unit flash uses, 1/20th of a pixel).

Source

pub fn dimensions(&self) -> (u32, u32)

Returns the dimensions in pixels (converted from twips, sometimes losing accuracy).

Source

pub fn frame_rate(&self) -> u16

Returns the frame rate (note: does not yet handle fractional framerates).

Source

pub fn frame_count(&self) -> u16

Returns the frame count.

Trait Implementations§

Source§

impl Clone for SwfHeaders

Source§

fn clone(&self) -> SwfHeaders

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SwfHeaders

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for SwfHeaders

Source§

fn eq(&self, other: &SwfHeaders) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for SwfHeaders

Source§

impl StructuralPartialEq for SwfHeaders

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.