# Trait hacspec_lib::prelude::Integer

source · [−]```
pub trait Integer: Numeric {
const NUM_BITS: usize;
fn ZERO() -> Self;
fn ONE() -> Self;
fn TWO() -> Self;
fn from_literal(val: u128) -> Self;
fn from_hex_string(s: &String) -> Self;
fn get_bit(self, i: usize) -> Self;
fn set_bit(self, b: Self, i: usize) -> Self;
fn set(self, pos: usize, y: Self, yi: usize) -> Self;
fn rotate_left(self, n: usize) -> Self;
fn rotate_right(self, n: usize) -> Self;
}
```

## Expand description

This trait extends the `Numeric`

trait and is implemented by all integer
types. It offers bit manipulation, instantiation from literal, and convenient
constants.

## Required Associated Constants

## Required Methods

#### fn from_literal(val: u128) -> Self

#### fn from_literal(val: u128) -> Self

Get an integer with value `val`

.

#### fn from_hex_string(s: &String) -> Self

#### fn from_hex_string(s: &String) -> Self

Read a hex string (starting with 0x) into an `Integer`

.

#### fn rotate_left(self, n: usize) -> Self

#### fn rotate_right(self, n: usize) -> Self

## Implementations on Foreign Types

source### impl Integer for u8

### impl Integer for u8

source#### fn ZERO() -> Self

#### fn ZERO() -> Self

*This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.*

source#### fn ONE() -> Self

#### fn ONE() -> Self

*This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.*

source#### fn TWO() -> Self

#### fn TWO() -> Self

*This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.*

source#### fn from_literal(val: u128) -> Self

#### fn from_literal(val: u128) -> Self

source#### fn from_hex_string(s: &String) -> Self

#### fn from_hex_string(s: &String) -> Self

*This function can be called from hacspec programs but its body features Rust constructs that are not part of hacspec*

source#### fn get_bit(self, i: usize) -> Self

#### fn get_bit(self, i: usize) -> Self

`i`

of this integer.

source#### fn set_bit(self, b: Self, i: usize) -> Self

#### fn set_bit(self, b: Self, i: usize) -> Self

`i`

of this integer to `b`

and return the result.
Bit `b`

has to be `0`

or `1`

.

source#### fn set(self, pos: usize, y: Self, yi: usize) -> Self

#### fn set(self, pos: usize, y: Self, yi: usize) -> Self

`pos`

of this integer to bit `yi`

of integer `y`

.

source#### fn rotate_left(self, n: usize) -> Self

#### fn rotate_left(self, n: usize) -> Self

source#### fn rotate_right(self, n: usize) -> Self

#### fn rotate_right(self, n: usize) -> Self

#### const NUM_BITS: usize = 8usize

source### impl Integer for u16

### impl Integer for u16

source#### fn ZERO() -> Self

#### fn ZERO() -> Self

source#### fn ONE() -> Self

#### fn ONE() -> Self

source#### fn TWO() -> Self

#### fn TWO() -> Self

source#### fn from_literal(val: u128) -> Self

#### fn from_literal(val: u128) -> Self

source#### fn from_hex_string(s: &String) -> Self

#### fn from_hex_string(s: &String) -> Self

*This function can be called from hacspec programs but its body features Rust constructs that are not part of hacspec*

source#### fn get_bit(self, i: usize) -> Self

#### fn get_bit(self, i: usize) -> Self

`i`

of this integer.

source#### fn set_bit(self, b: Self, i: usize) -> Self

#### fn set_bit(self, b: Self, i: usize) -> Self

`i`

of this integer to `b`

and return the result.
Bit `b`

has to be `0`

or `1`

.

source#### fn set(self, pos: usize, y: Self, yi: usize) -> Self

#### fn set(self, pos: usize, y: Self, yi: usize) -> Self

`pos`

of this integer to bit `yi`

of integer `y`

.

source#### fn rotate_left(self, n: usize) -> Self

#### fn rotate_left(self, n: usize) -> Self

source#### fn rotate_right(self, n: usize) -> Self

#### fn rotate_right(self, n: usize) -> Self

#### const NUM_BITS: usize = 16usize

source### impl Integer for u32

### impl Integer for u32

source#### fn ZERO() -> Self

#### fn ZERO() -> Self

source#### fn ONE() -> Self

#### fn ONE() -> Self

source#### fn TWO() -> Self

#### fn TWO() -> Self

source#### fn from_literal(val: u128) -> Self

#### fn from_literal(val: u128) -> Self

source#### fn from_hex_string(s: &String) -> Self

#### fn from_hex_string(s: &String) -> Self

*This function can be called from hacspec programs but its body features Rust constructs that are not part of hacspec*

source#### fn get_bit(self, i: usize) -> Self

#### fn get_bit(self, i: usize) -> Self

`i`

of this integer.

source#### fn set_bit(self, b: Self, i: usize) -> Self

#### fn set_bit(self, b: Self, i: usize) -> Self

`i`

of this integer to `b`

and return the result.
Bit `b`

has to be `0`

or `1`

.

source#### fn set(self, pos: usize, y: Self, yi: usize) -> Self

#### fn set(self, pos: usize, y: Self, yi: usize) -> Self

`pos`

of this integer to bit `yi`

of integer `y`

.

source#### fn rotate_left(self, n: usize) -> Self

#### fn rotate_left(self, n: usize) -> Self

source#### fn rotate_right(self, n: usize) -> Self

#### fn rotate_right(self, n: usize) -> Self

#### const NUM_BITS: usize = 32usize

source### impl Integer for u64

### impl Integer for u64

source#### fn ZERO() -> Self

#### fn ZERO() -> Self

source#### fn ONE() -> Self

#### fn ONE() -> Self

source#### fn TWO() -> Self

#### fn TWO() -> Self

source#### fn from_literal(val: u128) -> Self

#### fn from_literal(val: u128) -> Self

source#### fn from_hex_string(s: &String) -> Self

#### fn from_hex_string(s: &String) -> Self

source#### fn get_bit(self, i: usize) -> Self

#### fn get_bit(self, i: usize) -> Self

`i`

of this integer.

source#### fn set_bit(self, b: Self, i: usize) -> Self

#### fn set_bit(self, b: Self, i: usize) -> Self

`i`

of this integer to `b`

and return the result.
Bit `b`

has to be `0`

or `1`

.

source#### fn set(self, pos: usize, y: Self, yi: usize) -> Self

#### fn set(self, pos: usize, y: Self, yi: usize) -> Self

`pos`

of this integer to bit `yi`

of integer `y`

.

source#### fn rotate_left(self, n: usize) -> Self

#### fn rotate_left(self, n: usize) -> Self

source#### fn rotate_right(self, n: usize) -> Self

#### fn rotate_right(self, n: usize) -> Self

#### const NUM_BITS: usize = 64usize

source### impl Integer for u128

### impl Integer for u128

source#### fn ZERO() -> Self

#### fn ZERO() -> Self

source#### fn ONE() -> Self

#### fn ONE() -> Self

source#### fn TWO() -> Self

#### fn TWO() -> Self

source#### fn from_literal(val: u128) -> Self

#### fn from_literal(val: u128) -> Self

source#### fn from_hex_string(s: &String) -> Self

#### fn from_hex_string(s: &String) -> Self

source#### fn get_bit(self, i: usize) -> Self

#### fn get_bit(self, i: usize) -> Self

`i`

of this integer.

source#### fn set_bit(self, b: Self, i: usize) -> Self

#### fn set_bit(self, b: Self, i: usize) -> Self

`i`

of this integer to `b`

and return the result.
Bit `b`

has to be `0`

or `1`

.

source#### fn set(self, pos: usize, y: Self, yi: usize) -> Self

#### fn set(self, pos: usize, y: Self, yi: usize) -> Self

`pos`

of this integer to bit `yi`

of integer `y`

.

source#### fn rotate_left(self, n: usize) -> Self

#### fn rotate_left(self, n: usize) -> Self

source#### fn rotate_right(self, n: usize) -> Self

#### fn rotate_right(self, n: usize) -> Self

#### const NUM_BITS: usize = 128usize

source### impl Integer for i8

### impl Integer for i8

source#### fn ZERO() -> Self

#### fn ZERO() -> Self

source#### fn ONE() -> Self

#### fn ONE() -> Self

source#### fn TWO() -> Self

#### fn TWO() -> Self

source#### fn from_literal(val: u128) -> Self

#### fn from_literal(val: u128) -> Self

source#### fn from_hex_string(s: &String) -> Self

#### fn from_hex_string(s: &String) -> Self

source#### fn get_bit(self, i: usize) -> Self

#### fn get_bit(self, i: usize) -> Self

`i`

of this integer.

source#### fn set_bit(self, b: Self, i: usize) -> Self

#### fn set_bit(self, b: Self, i: usize) -> Self

`i`

of this integer to `b`

and return the result.
Bit `b`

has to be `0`

or `1`

.

source#### fn set(self, pos: usize, y: Self, yi: usize) -> Self

#### fn set(self, pos: usize, y: Self, yi: usize) -> Self

`pos`

of this integer to bit `yi`

of integer `y`

.

source#### fn rotate_left(self, n: usize) -> Self

#### fn rotate_left(self, n: usize) -> Self

source#### fn rotate_right(self, n: usize) -> Self

#### fn rotate_right(self, n: usize) -> Self

#### const NUM_BITS: usize = 8usize

source### impl Integer for i16

### impl Integer for i16

source#### fn ZERO() -> Self

#### fn ZERO() -> Self

source#### fn ONE() -> Self

#### fn ONE() -> Self

source#### fn TWO() -> Self

#### fn TWO() -> Self

source#### fn from_literal(val: u128) -> Self

#### fn from_literal(val: u128) -> Self

source#### fn from_hex_string(s: &String) -> Self

#### fn from_hex_string(s: &String) -> Self

source#### fn get_bit(self, i: usize) -> Self

#### fn get_bit(self, i: usize) -> Self

`i`

of this integer.

source#### fn set_bit(self, b: Self, i: usize) -> Self

#### fn set_bit(self, b: Self, i: usize) -> Self

`i`

of this integer to `b`

and return the result.
Bit `b`

has to be `0`

or `1`

.

source#### fn set(self, pos: usize, y: Self, yi: usize) -> Self

#### fn set(self, pos: usize, y: Self, yi: usize) -> Self

`pos`

of this integer to bit `yi`

of integer `y`

.

source#### fn rotate_left(self, n: usize) -> Self

#### fn rotate_left(self, n: usize) -> Self

source#### fn rotate_right(self, n: usize) -> Self

#### fn rotate_right(self, n: usize) -> Self

#### const NUM_BITS: usize = 16usize

source### impl Integer for i32

### impl Integer for i32

source#### fn ZERO() -> Self

#### fn ZERO() -> Self

source#### fn ONE() -> Self

#### fn ONE() -> Self

source#### fn TWO() -> Self

#### fn TWO() -> Self

source#### fn from_literal(val: u128) -> Self

#### fn from_literal(val: u128) -> Self

source#### fn from_hex_string(s: &String) -> Self

#### fn from_hex_string(s: &String) -> Self

source#### fn get_bit(self, i: usize) -> Self

#### fn get_bit(self, i: usize) -> Self

`i`

of this integer.

source#### fn set_bit(self, b: Self, i: usize) -> Self

#### fn set_bit(self, b: Self, i: usize) -> Self

`i`

of this integer to `b`

and return the result.
Bit `b`

has to be `0`

or `1`

.

source#### fn set(self, pos: usize, y: Self, yi: usize) -> Self

#### fn set(self, pos: usize, y: Self, yi: usize) -> Self

`pos`

of this integer to bit `yi`

of integer `y`

.

source#### fn rotate_left(self, n: usize) -> Self

#### fn rotate_left(self, n: usize) -> Self

source#### fn rotate_right(self, n: usize) -> Self

#### fn rotate_right(self, n: usize) -> Self

#### const NUM_BITS: usize = 32usize

source### impl Integer for i64

### impl Integer for i64

source#### fn ZERO() -> Self

#### fn ZERO() -> Self

source#### fn ONE() -> Self

#### fn ONE() -> Self

source#### fn TWO() -> Self

#### fn TWO() -> Self

source#### fn from_literal(val: u128) -> Self

#### fn from_literal(val: u128) -> Self

source#### fn from_hex_string(s: &String) -> Self

#### fn from_hex_string(s: &String) -> Self

source#### fn get_bit(self, i: usize) -> Self

#### fn get_bit(self, i: usize) -> Self

`i`

of this integer.

source#### fn set_bit(self, b: Self, i: usize) -> Self

#### fn set_bit(self, b: Self, i: usize) -> Self

`i`

of this integer to `b`

and return the result.
Bit `b`

has to be `0`

or `1`

.

source#### fn set(self, pos: usize, y: Self, yi: usize) -> Self

#### fn set(self, pos: usize, y: Self, yi: usize) -> Self

`pos`

of this integer to bit `yi`

of integer `y`

.

source#### fn rotate_left(self, n: usize) -> Self

#### fn rotate_left(self, n: usize) -> Self

source#### fn rotate_right(self, n: usize) -> Self

#### fn rotate_right(self, n: usize) -> Self

#### const NUM_BITS: usize = 64usize

source### impl Integer for i128

### impl Integer for i128

source#### fn ZERO() -> Self

#### fn ZERO() -> Self

source#### fn ONE() -> Self

#### fn ONE() -> Self

source#### fn TWO() -> Self

#### fn TWO() -> Self

source#### fn from_literal(val: u128) -> Self

#### fn from_literal(val: u128) -> Self

source#### fn from_hex_string(s: &String) -> Self

#### fn from_hex_string(s: &String) -> Self

source#### fn get_bit(self, i: usize) -> Self

#### fn get_bit(self, i: usize) -> Self

`i`

of this integer.

source#### fn set_bit(self, b: Self, i: usize) -> Self

#### fn set_bit(self, b: Self, i: usize) -> Self

`i`

of this integer to `b`

and return the result.
Bit `b`

has to be `0`

or `1`

.

source#### fn set(self, pos: usize, y: Self, yi: usize) -> Self

#### fn set(self, pos: usize, y: Self, yi: usize) -> Self

`pos`

of this integer to bit `yi`

of integer `y`

.