BitArrayTrait

Fully qualified path: alexandria_bytes::bit_array::BitArrayTrait

#![allow(unused)]
fn main() {
pub trait BitArrayTrait
}

Trait functions

new

Creates a new BitArray instance.

Arguments

  • data - Array of bytes31 data
  • current - Current working felt252 value
  • read_pos - Current read position
  • write_pos - Current write position

Fully qualified path: alexandria_bytes::bit_array::BitArrayTrait::new

#![allow(unused)]
fn main() {
fn new(data: Array<bytes31>, current: felt252, read_pos: usize, write_pos: usize) -> BitArray
}

current

Gets the current working felt252 value.

Arguments

  • self - The BitArray to get the current value from

Fully qualified path: alexandria_bytes::bit_array::BitArrayTrait::current

#![allow(unused)]
fn main() {
fn current(self: @BitArray) -> felt252
}

data

Gets the underlying data array.

Arguments

  • self - The BitArray to get the data from

Fully qualified path: alexandria_bytes::bit_array::BitArrayTrait::data

#![allow(unused)]
fn main() {
fn data(self: BitArray) -> Array<bytes31>
}

append_bit

Appends a single bit to the BitArray

Arguments

  • self - The BitArray to append to
  • bit - Either true or false, representing a single bit to be appended

Fully qualified path: alexandria_bytes::bit_array::BitArrayTrait::append_bit

#![allow(unused)]
fn main() {
fn append_bit(ref self: BitArray, bit: bool)
}

at

Reads a single bit from the array

Arguments

  • self - The BitArray to read from
  • index - The index into the array to read

Returns Option<bool>

  • if the index is found, the stored bool is returned

Fully qualified path: alexandria_bytes::bit_array::BitArrayTrait::at

#![allow(unused)]
fn main() {
fn at(self: @BitArray, index: usize) -> Option<bool>
}

len

The current length of the BitArray

Arguments

  • self - The BitArray to get the length of

Returns usize

  • length in bits of the BitArray

Fully qualified path: alexandria_bytes::bit_array::BitArrayTrait::len

#![allow(unused)]
fn main() {
fn len(self: @BitArray) -> usize
}

pop_front

Returns and removes the first element of the BitArray

Arguments

  • self - The BitArray to pop from

Returns Option<bool>

  • If the array is non-empty, a bool is removed from the front and returned

Fully qualified path: alexandria_bytes::bit_array::BitArrayTrait::pop_front

#![allow(unused)]
fn main() {
fn pop_front(ref self: BitArray) -> Option<bool>
}

read_word_be

Reads a single word of the specified length up to 248 bits in big endian bit representation

Arguments

  • self - The BitArray to read from
  • length - The bit length of the word to read, max 248

Returns Option<felt252>

  • If there are length bits remaining, the word is returned as felt252

Fully qualified path: alexandria_bytes::bit_array::BitArrayTrait::read_word_be

#![allow(unused)]
fn main() {
fn read_word_be(ref self: BitArray, length: usize) -> Option<felt252>
}

read_word_be_u256

Reads a single word of the specified length up to 256 bits in big endian representation. For words shorter than (or equal to) 248 bits use read_word_be(...) instead.

Arguments

  • self - The BitArray to read from
  • length - The bit length of the word to read, max 256

Returns Option<u256>

  • If there are length bits remaining, the word is returned as u256

Fully qualified path: alexandria_bytes::bit_array::BitArrayTrait::read_word_be_u256

#![allow(unused)]
fn main() {
fn read_word_be_u256(ref self: BitArray, length: usize) -> Option<u256>
}

read_word_be_u512

Reads a single word of the specified length up to 512 bits in big endian representation. For words shorter than (or equal to) 256 bits consider the other read calls instead.

Arguments

  • self - The BitArray to read from
  • length - The bit length of the word to read, max 512

Returns Option<u512>

  • If there are length bits remaining, the word is returned as u512

Fully qualified path: alexandria_bytes::bit_array::BitArrayTrait::read_word_be_u512

#![allow(unused)]
fn main() {
fn read_word_be_u512(ref self: BitArray, length: usize) -> Option<u512>
}

write_word_be

Writes the bits of the specified length from word onto the BitArray in big endian representation

Arguments

  • self - The BitArray to write to
  • word - The value to store onto the bit array of type felt252 - length - The length of the word in bits, maximum 248

Fully qualified path: alexandria_bytes::bit_array::BitArrayTrait::write_word_be

#![allow(unused)]
fn main() {
fn write_word_be(ref self: BitArray, word: felt252, length: usize)
}

write_word_be_u256

Writes the bits of the specified length from word onto the BitArray in big endian representation

Arguments

  • self - The BitArray to write to
  • word - The value to store onto the bit array of type u256
  • length - The length of the word in bits, maximum 256

Fully qualified path: alexandria_bytes::bit_array::BitArrayTrait::write_word_be_u256

#![allow(unused)]
fn main() {
fn write_word_be_u256(ref self: BitArray, word: u256, length: usize)
}

write_word_be_u512

Writes the bits of the specified length from word onto the BitArray in big endian representation

Arguments

  • self - The BitArray to write to
  • word - The value to store onto the bit array of type u512
  • length - The length of the word in bits, maximum 512

Fully qualified path: alexandria_bytes::bit_array::BitArrayTrait::write_word_be_u512

#![allow(unused)]
fn main() {
fn write_word_be_u512(ref self: BitArray, word: u512, length: usize)
}

read_word_le

Reads a single word of the specified length up to 248 bits in little endian bit representation

Arguments

  • self - The BitArray to read from
  • length - The bit length of the word to read, max 248

Returns Option<felt252>

  • If there are length bits remaining, the word is returned as felt252

Fully qualified path: alexandria_bytes::bit_array::BitArrayTrait::read_word_le

#![allow(unused)]
fn main() {
fn read_word_le(ref self: BitArray, length: usize) -> Option<felt252>
}

read_word_le_u256

Reads a single word of the specified length up to 256 bits in little endian representation. For words shorter than (or equal to) 248 bits use read_word_be(...) instead.

Arguments

  • self - The BitArray to read from
  • length - The bit length of the word to read, max 256

Returns Option<u256>

  • If there are length bits remaining, the word is returned as u256

Fully qualified path: alexandria_bytes::bit_array::BitArrayTrait::read_word_le_u256

#![allow(unused)]
fn main() {
fn read_word_le_u256(ref self: BitArray, length: usize) -> Option<u256>
}

read_word_le_u512

Reads a single word of the specified length up to 512 bits in little endian representation. For words shorter than (or equal to) 256 bits consider the other read calls instead.

Arguments

  • self - The BitArray to read from
  • length - The bit length of the word to read, max 512

Returns Option<u512>

  • If there are length bits remaining, the word is returned as u512

Fully qualified path: alexandria_bytes::bit_array::BitArrayTrait::read_word_le_u512

#![allow(unused)]
fn main() {
fn read_word_le_u512(ref self: BitArray, length: usize) -> Option<u512>
}

write_word_le

Writes the bits of the specified length from word onto the BitArray in little endian representation

Arguments

  • self - The BitArray to write to
  • word - The value to store onto the bit array of type felt252
  • length - The length of the word in bits, maximum 248

Fully qualified path: alexandria_bytes::bit_array::BitArrayTrait::write_word_le

#![allow(unused)]
fn main() {
fn write_word_le(ref self: BitArray, word: felt252, length: usize)
}

write_word_le_u256

Writes the bits of the specified length from word onto the BitArray in little endian representation

Arguments

  • self - The BitArray to write to
  • word - The value to store onto the bit array of type u256
  • length - The length of the word in bits, maximum 256

Fully qualified path: alexandria_bytes::bit_array::BitArrayTrait::write_word_le_u256

#![allow(unused)]
fn main() {
fn write_word_le_u256(ref self: BitArray, word: u256, length: usize)
}

write_word_le_u512

Writes the bits of the specified length from word onto the BitArray in little endian representation

Arguments

  • self - The BitArray to write to
  • word - The value to store onto the bit array of type u512
  • length - The length of the word in bits, maximum 512

Fully qualified path: alexandria_bytes::bit_array::BitArrayTrait::write_word_le_u512

#![allow(unused)]
fn main() {
fn write_word_le_u512(ref self: BitArray, word: u512, length: usize)
}