Skip to main content

PrimitiveOp

Enum PrimitiveOp 

Source
#[repr(u8)]
pub enum PrimitiveOp {
Show 18 variants Neg = 0, Bnot = 1, Succ = 2, Pred = 3, Add = 4, Sub = 5, Mul = 6, Xor = 7, And = 8, Or = 9, Le = 10, Lt = 11, Ge = 12, Gt = 13, Concat = 14, Div = 15, Mod = 16, Pow = 17,
}
Expand description

The 18 primitive operations defined in the UOR Foundation. 10 original (Neg/Bnot/Succ/Pred/Add/Sub/Mul/Xor/And/Or), 5 ADR-013/TR-08 substrate amendments (Le/Lt/Ge/Gt/Concat), 3 ADR-053 ring-axis completion (Div/Mod/Pow).

Variants§

§

Neg = 0

Ring reflection: neg(x) = (-x) mod 2^n. One of the two generators of the dihedral group D_{2^n}. neg(neg(x)) = x (involution property).

§

Bnot = 1

Hypercube reflection: bnot(x) = (2^n - 1) ⊕ x (bitwise complement). The second generator of D_{2^n}. bnot(bnot(x)) = x.

§

Succ = 2

Successor: succ(x) = neg(bnot(x)) = (x + 1) mod 2^n. The critical identity: succ is the composition neg ∘ bnot.

§

Pred = 3

Predecessor: pred(x) = bnot(neg(x)) = (x - 1) mod 2^n. The inverse of succ. pred is the composition bnot ∘ neg.

§

Add = 4

Ring addition: add(x, y) = (x + y) mod 2^n. Commutative, associative; identity element is 0.

§

Sub = 5

Ring subtraction: sub(x, y) = (x - y) mod 2^n. Not commutative, not associative.

§

Mul = 6

Ring multiplication: mul(x, y) = (x × y) mod 2^n. Commutative, associative; identity element is 1.

§

Xor = 7

Bitwise exclusive or: xor(x, y) = x ⊕ y. Commutative, associative; identity element is 0.

§

And = 8

Bitwise and: and(x, y) = x ∧ y. Commutative, associative.

§

Or = 9

Bitwise or: or(x, y) = x ∨ y. Commutative, associative.

§

Le = 10

Byte-level less-than-or-equal: le(x, y) = 1 if x ≤ y else 0. Operands compared as big-endian unsigned byte sequences. The catamorphism fold-rule emits Literal(1) on true, Literal(0) on false.

§

Lt = 11

Byte-level less-than: lt(x, y) = 1 if x < y else 0. Operands compared as big-endian unsigned byte sequences.

§

Ge = 12

Byte-level greater-than-or-equal: ge(x, y) = 1 if x ≥ y else 0. Operands compared as big-endian unsigned byte sequences.

§

Gt = 13

Byte-level greater-than: gt(x, y) = 1 if x > y else 0. Operands compared as big-endian unsigned byte sequences.

§

Concat = 14

Byte-sequence concatenation: concat(x, y) = x ⧺ y. The substrate’s byte-packing primitive — admits header serialization and other byte-array construction patterns. Result length is len(x) + len(y), bounded by the foundation’s TERM_VALUE_MAX_BYTES ceiling.

§

Div = 15

Euclidean quotient: div(a, b) = q where a = q·b + r, 0 ⇐ r < b. Total on the ring for b > 0; b = 0 emits a ShapeViolation. Operands read as unsigned big-endian integers at the operand width.

§

Mod = 16

Euclidean remainder: mod(a, b) = r where a = q·b + r, 0 ⇐ r < b. Total on the ring for b > 0; b = 0 emits a ShapeViolation. Operands read as unsigned big-endian integers at the operand width.

§

Pow = 17

Modular exponentiation: pow(base, exp) = base^exp mod 2^n. Fold-rule: square-and-multiply over exp bits. pow(_, 0) = 1; pow(0, b > 0) = 0.

Implementations§

Source§

impl PrimitiveOp

Source

pub const fn arity(self) -> i64

Returns the arity of this operation (1 for unary, 2 for binary).

Source

pub const fn is_commutative(self) -> bool

Returns whether this operation is commutative.

Source

pub const fn is_involution(self) -> bool

Returns whether this operation is an involution (self-inverse).

Source

pub const fn has_geometric_character(self) -> GeometricCharacter

Returns the geometric character of this operation.

Source

pub const fn is_unary(self) -> bool

Returns true if this is a unary operation.

Source

pub const fn is_binary(self) -> bool

Returns true if this is a binary operation.

Trait Implementations§

Source§

impl Clone for PrimitiveOp

Source§

fn clone(&self) -> PrimitiveOp

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 PrimitiveOp

Source§

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

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

impl Default for PrimitiveOp

Source§

fn default() -> PrimitiveOp

Returns the “default value” for a type. Read more
Source§

impl Display for PrimitiveOp

Source§

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

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

impl Hash for PrimitiveOp

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for PrimitiveOp

Source§

fn cmp(&self, other: &PrimitiveOp) -> 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 PrimitiveOp

Source§

fn eq(&self, other: &PrimitiveOp) -> 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 PrimitiveOp

Source§

fn partial_cmp(&self, other: &PrimitiveOp) -> 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
Source§

impl Copy for PrimitiveOp

Source§

impl Eq for PrimitiveOp

Source§

impl StructuralPartialEq for PrimitiveOp

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> Same for T

Source§

type Output = T

Should always be Self
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.