Skip to main content

Pcr

Struct Pcr 

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

Program Clock Reference (ISO/IEC 13818-1:2007 §2.4.3.5): a 33-bit base on a 90 kHz clock plus a 9-bit extension on a 27 MHz clock.

Fields§

§base: u64

33-bit base (90 kHz units).

§extension: u16

9-bit extension (27 MHz units).

Implementations§

Source§

impl Pcr

Source

pub fn as_27mhz(self) -> u64

Full PCR value on the 27 MHz clock: base * 300 + extension.

ISO/IEC 13818-1:2007 §2.4.3.5: PCR = PCR_base * 300 + PCR_ext.

Source

pub fn from_27mhz(ticks: u64) -> Self

Construct a Pcr from an absolute 27 MHz clock value.

Decomposes ticks into base = ticks / 300 and extension = ticks % 300, clamping each to its wire width (33-bit base, 9-bit extension) — ISO/IEC 13818-1:2007 §2.4.3.5.

Round-trips with as_27mhz: Pcr::from_27mhz(p.as_27mhz()) == p for any valid Pcr.

Source

pub fn to_field_bytes(self) -> [u8; 6]

Encode as the exact 6-byte PCR/OPCR field used in the adaptation field (ISO/IEC 13818-1:2007 §2.4.3.5).

Wire layout (big-endian, 48 bits): [base[32:25]][base[24:17]][base[16:9]][base[8:1]][base[0] | 6×reserved(1) | ext[8]][ext[7:0]]

The 6 reserved bits are set to 1 as per the spec’s “reserved” convention. Exact inverse of the private parse function.

Trait Implementations§

Source§

impl Clone for Pcr

Source§

fn clone(&self) -> Pcr

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 Pcr

Source§

impl Debug for Pcr

Source§

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

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

impl Eq for Pcr

Source§

impl PartialEq for Pcr

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 Serialize for Pcr

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 Pcr

Auto Trait Implementations§

§

impl Freeze for Pcr

§

impl RefUnwindSafe for Pcr

§

impl Send for Pcr

§

impl Sync for Pcr

§

impl Unpin for Pcr

§

impl UnsafeUnpin for Pcr

§

impl UnwindSafe for Pcr

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.