Skip to main content

Scr

Struct Scr 

Source
pub struct Scr {
    pub base: u64,
    pub extension: u16,
}
Expand description

System Clock Reference (42-bit total: 33-bit base + 9-bit extension, in 27 MHz units).

Fields§

§base: u64

33-bit SCR base (27 MHz ticks, integer part).

§extension: u16

9-bit SCR extension (27 MHz ticks, fractional part / 300).

Implementations§

Source§

impl Scr

Source

pub const fn ticks(self) -> u64

The total SCR value in 27 MHz ticks.

base * 300 + extension.

Examples found in repository?
examples/parse_pack_header.rs (line 19)
9fn main() {
10    // A minimal pack header (from the fixture pattern):
11    // start_code 0x000001BA, SCR=0, mux_rate=0x10CD8E, reserved=0x1F, stuffing=0
12    let bytes = [
13        0x00, 0x00, 0x01, 0xBA, 0x44, 0x00, 0x04, 0x00, 0x04, 0x01, 0x43, 0x36, 0x3B, 0xF8,
14    ];
15    let header = PackHeader::parse(&bytes).unwrap();
16    println!("pack_start_code:       0x000001BA");
17    println!("SCR base:              {}", header.scr.base);
18    println!("SCR extension:         {}", header.scr.extension);
19    println!("SCR ticks:             {}", header.scr.ticks());
20    println!("SCR seconds:           {:.6}", header.scr.seconds());
21    println!(
22        "program_mux_rate:      {} ({} B/s)",
23        header.program_mux_rate,
24        header.program_mux_rate * 50
25    );
26    println!("pack_stuffing_length:  {}", header.stuffing_length);
27    println!("reserved:              {}", header.reserved);
28}
Source

pub fn seconds(self) -> f64

Value in seconds.

Examples found in repository?
examples/parse_pack_header.rs (line 20)
9fn main() {
10    // A minimal pack header (from the fixture pattern):
11    // start_code 0x000001BA, SCR=0, mux_rate=0x10CD8E, reserved=0x1F, stuffing=0
12    let bytes = [
13        0x00, 0x00, 0x01, 0xBA, 0x44, 0x00, 0x04, 0x00, 0x04, 0x01, 0x43, 0x36, 0x3B, 0xF8,
14    ];
15    let header = PackHeader::parse(&bytes).unwrap();
16    println!("pack_start_code:       0x000001BA");
17    println!("SCR base:              {}", header.scr.base);
18    println!("SCR extension:         {}", header.scr.extension);
19    println!("SCR ticks:             {}", header.scr.ticks());
20    println!("SCR seconds:           {:.6}", header.scr.seconds());
21    println!(
22        "program_mux_rate:      {} ({} B/s)",
23        header.program_mux_rate,
24        header.program_mux_rate * 50
25    );
26    println!("pack_stuffing_length:  {}", header.stuffing_length);
27    println!("reserved:              {}", header.reserved);
28}

Trait Implementations§

Source§

impl Clone for Scr

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Scr

Source§

impl Debug for Scr

Source§

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

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

impl Eq for Scr

Source§

impl PartialEq for Scr

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for Scr

Available on crate feature serde only.
Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Scr

Auto Trait Implementations§

§

impl Forget for Scr

§

impl Freeze for Scr

§

impl RefUnwindSafe for Scr

§

impl Send for Scr

§

impl Sync for Scr

§

impl Unpin for Scr

§

impl UnsafeUnpin for Scr

§

impl UnwindSafe for Scr

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.