Skip to main content

EagleTime

Struct EagleTime 

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

EagleTime represents a point in time in the Eagle Time standard.

Stores time as oscillation counts of the 21cm hydrogen-1 hyperfine transition.

Eagle epoch: Apollo 11 lunar landing - July 20, 1969 at 20:17:40 UTC (The moment “The Eagle has landed” was transmitted)

This definition:

  • Uses the most abundant element in the universe (hydrogen-1)
  • Is measurable with any 21cm radio receiver
  • Accounts for gravitational time dilation in the frequency measurement
  • Provides universal verifiability without trusted authorities
  • Achieves picosecond precision with standard integer types

§Precision Characteristics

TypeRangePrecisionUse Case
e5±1.5 years704 psShort intervals, packed structs
e6±206 years704 psAbsolute timestamps (default)
e7astronomical704 psGeological/astronomical timestamps

Implementations§

Source§

impl EagleTime

Source

pub fn new_from_vsf(value: VsfType) -> Self

Creates a new EagleTime instance from a VsfType.

Integer types are interpreted as oscillation counts. Float types are interpreted as seconds.

§Panics

Panics if the VsfType is not a valid numeric variant or EagleTime type.

Source

pub fn new(et_seconds: EtType) -> Self

Creates a new EagleTime directly from an EtType

Source

pub fn from_oscillations(count: i64) -> Self

Creates an EagleTime from an oscillation count (i64)

Source

pub fn from_seconds_f64(seconds: f64) -> Self

Creates an EagleTime from seconds (f64), converting to oscillation count

Source

pub fn from_seconds_f32(seconds: f32) -> Self

Creates an EagleTime from seconds (f32), converting to oscillation count

Source

pub fn to_vsf_type(&self) -> VsfType

Converts the current EagleTime to a VsfType.

Source

pub fn to_datetime_opt(&self) -> Option<DateTime<Utc>>

Converts the EagleTime to a UTC DateTime.

For integer types, divides oscillation count by OSCILLATIONS_PER_SECOND. For float types, uses the stored seconds directly.

Returns None if the timestamp is outside chrono’s representable range.

Source

pub fn to_datetime(&self) -> DateTime<Utc>

Converts the EagleTime to a UTC DateTime.

Panics if the timestamp is outside chrono’s representable range. For non-panicking version, use to_datetime_opt().

Source

pub fn et_type(&self) -> &EtType

Get a reference to the underlying EtType

Source

pub fn to_seconds_f64(&self) -> f64

Converts to f64 seconds, regardless of storage type.

For integer types: divides oscillation count by OSCILLATIONS_PER_SECOND. For float types (deprecated): returns the stored seconds directly.

Source

pub fn to_seconds_f32(&self) -> f32

Converts to f32 seconds, regardless of storage type.

Source

pub fn oscillations(&self) -> Option<i64>

Returns the oscillation count as i64 if stored as an integer type, None for deprecated float types.

Examples found in repository?
examples/debug_vsf_bytes.rs (line 23)
4fn main() {
5    // Simulate what vsf_builder does
6    let mut vsf: Vec<Vec<u8>> = Vec::new();
7
8    // Magic + header start
9    vsf.push("RÅ".as_bytes().to_vec());
10    vsf[0].push(b'<');
11
12    // Header length placeholder
13    vsf.push(VsfType::b(0, true).flatten());
14
15    // Version and backward compat (in same vec)
16    let header_index = vsf.len();
17    vsf.push(VsfType::z(2).flatten());
18    vsf[header_index].extend_from_slice(&VsfType::y(2).flatten());
19
20    // Creation time (e6 — 64-bit oscillation count)
21    let now = Utc::now();
22    let et = vsf::datetime_to_eagle_time(now);
23    let oscillations = et.oscillations().unwrap_or(0);
24    let creation_time = VsfType::e(EtType::e6(oscillations));
25    vsf[header_index].extend_from_slice(&creation_time.flatten());
26
27    // Hash placeholder
28    vsf[header_index].extend_from_slice(&VsfType::hb(vec![0u8; 32]).flatten());
29
30    // Flatten
31    let bytes: Vec<u8> = vsf.into_iter().flatten().collect();
32
33    println!("Total bytes: {}", bytes.len());
34    println!("\nFirst 60 bytes with positions:");
35    for (i, &b) in bytes.iter().take(60).enumerate() {
36        if i % 16 == 0 {
37            println!();
38            print!("{:04X}: ", i);
39        }
40        print!("{:02X} ", b);
41    }
42    println!("\n");
43
44    // Find where 'h' appears
45    for (i, &b) in bytes.iter().enumerate().take(40) {
46        if b == b'h' {
47            println!("Found 'h' at position {}", i);
48        }
49    }
50
51    // Parse like verification does
52    println!("\nParsing simulation:");
53    let mut pointer = 0;
54
55    // Skip magic
56    pointer += 3; // "RÅ"
57    pointer += 1; // '<'
58    println!("After magic: pointer = {}", pointer);
59
60    // Parse header length
61    let hl_start = pointer;
62    if bytes[pointer] == b'b' {
63        pointer += 1;
64        let len_marker = bytes[pointer];
65        pointer += 1;
66        println!(
67            "Header length type at {}, marker={}, pointer now={}",
68            hl_start, len_marker as char, pointer
69        );
70    }
71
72    // Parse version (z)
73    let v_start = pointer;
74    if bytes[pointer] == b'z' {
75        pointer += 1;
76        let len_marker = bytes[pointer];
77        pointer += 1;
78        println!(
79            "Version at {}, marker={}, pointer now={}",
80            v_start, len_marker as char, pointer
81        );
82    }
83
84    // Parse backward compat (y)
85    let bc_start = pointer;
86    if bytes[pointer] == b'y' {
87        pointer += 1;
88        let len_marker = bytes[pointer];
89        pointer += 1;
90        println!(
91            "Backward compat at {}, marker={}, pointer now={}",
92            bc_start, len_marker as char, pointer
93        );
94    }
95
96    // Parse creation time (e)
97    let et_start = pointer;
98    if bytes[pointer] == b'e' {
99        pointer += 1;
100        if bytes[pointer] == b'f' {
101            pointer += 1;
102            if bytes[pointer] == b'5' {
103                pointer += 1;
104                pointer += 4; // f32
105                println!("Eagle Time (ef5) at {}, pointer now={}", et_start, pointer);
106            }
107        }
108    }
109
110    // Now we should be at the hash
111    println!(
112        "\nAt position {}: byte = 0x{:02X} ('{}')",
113        pointer, bytes[pointer], bytes[pointer] as char
114    );
115    if bytes[pointer] == b'h' {
116        println!("SUCCESS: Found hash placeholder at correct position!");
117    } else {
118        println!("ERROR: Expected 'h', found something else");
119    }
120}
Source

pub fn oscillations_i128(&self) -> Option<i128>

Returns the full i128 oscillation count. Covers e5/e6/e7 without truncation.

Source

pub fn picoseconds(&self) -> Option<i128>

Returns the picosecond precision timestamp (oscillations × 704.032 ps). Returns None for deprecated float types.

Trait Implementations§

Source§

impl Clone for EagleTime

Source§

fn clone(&self) -> EagleTime

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 Debug for EagleTime

Source§

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

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

impl Eq for EagleTime

Source§

impl Ord for EagleTime

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for EagleTime

Source§

fn eq(&self, other: &Self) -> 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 PartialOrd for EagleTime

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more

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.