Skip to main content

dispatch_ring

Macro dispatch_ring 

Source
macro_rules! dispatch_ring {
    ($ring:expr, $body:expr) => { ... };
    ($ring:expr, $body:expr, else $fallback:expr) => { ... };
}
Expand description

Dispatch a runtime ring: u8 value to a generic body that wants a concrete ZZn type. The body is evaluated in a context where:

  • ZZ is a type alias for the matching ZZn ring,
  • PHI is a const usize equal to that ring’s phi(n) (storage width of the integer-basis representation).

Two forms:

// Panic on unknown ring (typical for CLI / internal call sites):
dispatch_ring!(ring, body)

// Fallback expression on unknown ring (typical for WASM /
// user-facing entry points that prefer a structured error):
dispatch_ring!(ring, body, else fallback)

The bare form expands to the else form with a panic fallback, so both share the same per-ring match table; adding a ring touches exactly one place.