pub struct WittLevel { /* private fields */ }Expand description
A Witt level W_n at which the UOR ring R_n = Z/2^n Z operates.
Corresponds to schema:WittLevel in the uor.foundation ontology.
The class is open: any positive multiple of 8 identifies a valid level.
Named levels W8 through W32 are provided as associated constants.
Arbitrary levels can be constructed with WittLevel::new(n).
§Examples
use uor_foundation::WittLevel;
// Named reference levels (W8-W32 are spec-defined):
let w8 = WittLevel::W8;
assert_eq!(w8.witt_length(), 8);
assert_eq!(w8.bits_width(), 8); // Witt length IS bit width
assert_eq!(w8.cycle_size(), Some(256)); // 2^8 = 256 ring elements
let w32 = WittLevel::W32;
assert_eq!(w32.bits_width(), 32); // 32 bits
// Arbitrary levels beyond W32 (Prism-declared):
let w64 = WittLevel::new(64);
assert_eq!(w64.bits_width(), 64); // 64 bits — native u64
// The chain is unbounded:
let w88 = WittLevel::new(88);
assert_eq!(w88.bits_width(), 88);
assert_eq!(w88.next_witt_level().witt_length(), 96);
// Ordering follows the Witt length:
assert!(WittLevel::W8 < WittLevel::W32);Implementations§
Source§impl WittLevel
impl WittLevel
Sourcepub const W8: Self
pub const W8: Self
Witt level 8: 8-bit ring Z/256Z, 256 states. The reference level for all ComputationCertificate proofs in the spec.
Sourcepub const W32: Self
pub const W32: Self
Witt level 32: 32-bit ring Z/4294967296Z, 4,294,967,296 states. The highest named level in the spec.
Sourcepub const fn new(witt_length: u32) -> Self
pub const fn new(witt_length: u32) -> Self
Construct an arbitrary Witt level W_n. n need not be one of the spec-named individuals; Prism implementations may use any level.
Sourcepub const fn witt_length(self) -> u32
pub const fn witt_length(self) -> u32
The Witt length n. Maps to schema:wittLength.
Sourcepub const fn bits_width(self) -> u32
pub const fn bits_width(self) -> u32
Bit width of the ring at this level: equal to the Witt length. Maps to schema:bitsWidth. This is an identity — the Witt length IS the bit width.
Sourcepub const fn cycle_size(self) -> Option<u128>
pub const fn cycle_size(self) -> Option<u128>
Number of distinct ring states at this level: 2^n. Maps to schema:cycleSize. Returns None if the result exceeds u128 (i.e. for n > 128).
Sourcepub const fn next_witt_level(self) -> Self
pub const fn next_witt_level(self) -> Self
The next Witt level in the chain: W_n -> W_{n+8}. Maps to schema:nextWittLevel. Always well-defined; the chain is unbounded.