Starknet Alexandria Library Documents

About

Alexandria is a community maintained standard library for Cairo. It is a collection of useful algorithms and data structures implemented in Cairo.

Version

Actual version is 0.5.1 compatible with starknet 2.11.2

Features

This repository is composed of multiple crates:

Getting Started

Prerequisites

Installation from Scarb registries

  • ASCII : scarb add alexandria_ascii@0.5.1
  • Bytes : scarb add alexandria_bytes@0.5.1
  • Data Structures : scarb add alexandria_data_structures@0.5.1
  • Encoding : scarb add alexandria_encoding@0.5.1
  • Evm : scarb add alexandria_evm@0.5.1
  • Linalg : scarb add alexandria_linalg@0.5.1
  • Math : scarb add alexandria_math@0.5.1
  • MerkleTree: scarb add alexandria_merkle_tree@0.5.1
  • Numeric : scarb add alexandria_numeric@0.5.1
  • Searching : scarb add alexandria_searching@0.5.1
  • Sorting : scarb add alexandria_sorting@0.5.1
  • Storage : scarb add alexandria_storage@0.5.1
  • Utils : scarb add alexandria_utils@0.5.1

Usage

Build

scarb build

Test

scarb test

Running a specific subset of tests

scarb test -f math

Format

scarb fmt

Roadmap

See the open issues for a list of proposed features (and known issues).

Support

Reach out to the maintainer at one of the following places:

Project assistance

If you want to say thank you or/and support active development of Alexandria:

  • Add a GitHub Star to the project.
  • Tweet about the Alexandria.
  • Write interesting articles about the project on Dev.to, Medium or your personal blog.

Together, we can make Alexandria better!

alexandria_ascii

Fully qualified path: alexandria_ascii

integer

Fully qualified path: alexandria_ascii::integer

Traits

ToAsciiTrait

Fully qualified path: alexandria_ascii::integer::ToAsciiTrait

#![allow(unused)]
fn main() {
pub trait ToAsciiTrait<T, U>
}

Trait functions

to_ascii

Fully qualified path: alexandria_ascii::integer::ToAsciiTrait::to_ascii

#![allow(unused)]
fn main() {
fn to_ascii(self: T) -> U
}

ToAsciiArrayTrait

Fully qualified path: alexandria_ascii::integer::ToAsciiArrayTrait

#![allow(unused)]
fn main() {
pub trait ToAsciiArrayTrait<T>
}

Trait functions

to_ascii_array

Converts an integer to an array of its individual ASCII values in normal order

Arguments

  • self - The integer value to convert to ASCII array

Fully qualified path: alexandria_ascii::integer::ToAsciiArrayTrait::to_ascii_array

#![allow(unused)]
fn main() {
fn to_ascii_array(self: T) -> Array<felt252>
}

to_inverse_ascii_array

Converts an integer to an array of its individual ASCII values in reverse order

Arguments

  • self - The integer value to convert to inverse ASCII array

Fully qualified path: alexandria_ascii::integer::ToAsciiArrayTrait::to_inverse_ascii_array

#![allow(unused)]
fn main() {
fn to_inverse_ascii_array(self: T) -> Array<felt252>
}

Alexandria Bytes

Fully qualified path: alexandria_bytes

Modules

alexandria_bytes

Fully qualified path: alexandria_bytes

Modules

Structs

Traits

Impls

bit_array

Fully qualified path: alexandria_bytes::bit_array

Free functions

Structs

Traits

byte_appender

Fully qualified path: alexandria_bytes::byte_appender

Traits

byte_array_ext

Fully qualified path: alexandria_bytes::byte_array_ext

Traits

Impls

byte_reader

Fully qualified path: alexandria_bytes::byte_reader

Structs

Traits

bytes

Fully qualified path: alexandria_bytes::bytes

Constants

Structs

Traits

Impls

reversible

Fully qualified path: alexandria_bytes::reversible

Free functions

Traits

storage

Fully qualified path: alexandria_bytes::storage

Impls

utils

Fully qualified path: alexandria_bytes::utils

Free functions

Impls

Constants

BYTES_PER_ELEMENT

Bytes is a dynamic array of u128, where each element contains 16 bytes.

Fully qualified path: alexandria_bytes::bytes::BYTES_PER_ELEMENT

#![allow(unused)]
fn main() {
pub const BYTES_PER_ELEMENT: usize = 16;
}

Free functions

shift_bit

Fully qualified path: alexandria_bytes::bit_array::shift_bit

#![allow(unused)]
fn main() {
pub fn shift_bit(number: usize) -> u8
}

one_shift_left_bytes_felt252

Fully qualified path: alexandria_bytes::bit_array::one_shift_left_bytes_felt252

#![allow(unused)]
fn main() {
pub fn one_shift_left_bytes_felt252(n_bytes: usize) -> felt252
}

one_shift_left_bytes_u128

Fully qualified path: alexandria_bytes::bit_array::one_shift_left_bytes_u128

#![allow(unused)]
fn main() {
pub fn one_shift_left_bytes_u128(n_bytes: usize) -> u128
}

reversing

Fully qualified path: alexandria_bytes::reversible::reversing

#![allow(unused)]
fn main() {
pub fn reversing<
    T,
    +Copy<T>,
    +Zero<T>,
    +TryInto<T, NonZero<T>>,
    +DivRem<T>,
    +Drop<T>,
    +MulAssign<T, T>,
    +Rem<T>,
    +AddAssign<T, T>,
>(
    word: T, size: usize, step: T,
) -> (T, T)
}

reversing_partial_result

Fully qualified path: alexandria_bytes::reversible::reversing_partial_result

#![allow(unused)]
fn main() {
pub fn reversing_partial_result<
    T,
    +Copy<T>,
    +DivRem<T>,
    +TryInto<T, NonZero<T>>,
    +Drop<T>,
    +MulAssign<T, T>,
    +Rem<T>,
    +AddAssign<T, T>,
>(
    mut word: T, mut onto: T, size: usize, step: T,
) -> (T, T)
}

keccak_u128s_be

Computes the keccak256 of multiple uint128 values. The values are interpreted as big-endian. https://github.com/starkware-libs/cairo/blob/main/corelib/src/keccak.cairo

Fully qualified path: alexandria_bytes::utils::keccak_u128s_be

#![allow(unused)]
fn main() {
pub fn keccak_u128s_be(input: Span<u128>, n_bytes: usize) -> u256
}

u256_reverse_endian

Reverses the endianness of a u256 value.

Arguments

  • input - The u256 value to reverse endianness

Fully qualified path: alexandria_bytes::utils::u256_reverse_endian

#![allow(unused)]
fn main() {
pub fn u256_reverse_endian(input: u256) -> u256
}

u8_array_to_u256

Convert sha256 result(Array) to u256

Arguments

  • arr - Span of u8 values, length MUST be 32

Fully qualified path: alexandria_bytes::utils::u8_array_to_u256

#![allow(unused)]
fn main() {
pub fn u8_array_to_u256(arr: Span<u8>) -> u256
}

u32s_to_u256

Converts an array of 8 u32 values to a u256 value.

Arguments

  • arr - Span of u32 values (must be exactly 8 elements)

Fully qualified path: alexandria_bytes::utils::u32s_to_u256

#![allow(unused)]
fn main() {
pub fn u32s_to_u256(arr: Span<u32>) -> u256
}

u128_array_slice

Returns the slice of an array.

Arguments

  • arr - The array to slice.
  • begin - The index to start the slice at.
  • len - The length of the slice.

Returns

  • Array<u128> - The slice of the array.

Fully qualified path: alexandria_bytes::utils::u128_array_slice

#![allow(unused)]
fn main() {
pub fn u128_array_slice(src: @Array<u128>, mut begin: usize, len: usize) -> Array<u128>
}

u128_split

Split a u128 into two parts, [0, left_size-1] and [left_size, end].

Arguments

  • value - Data of u128
  • value_size - The size of value in bytes
  • left_size - The size of left part in bytes

Returns

  • left - [0, left_size-1] of the origin u128
  • right - [left_size, end] of the origin u128 which size is (value_size - left_size)

Examples

  • u128_split(0x01020304, 4, 0) -> (0, 0x01020304)
  • u128_split(0x01020304, 4, 1) -> (0x01, 0x020304)
  • u128_split(0x0001020304, 5, 1) -> (0x00, 0x01020304)

Fully qualified path: alexandria_bytes::utils::u128_split

#![allow(unused)]
fn main() {
pub fn u128_split(value: u128, value_size: usize, left_size: usize) -> (u128, u128)
}

read_sub_u128

Read sub value from u128 just like substr in other language.

Arguments

  • value - Data of u128
  • value_size - The size of data in bytes
  • offset - The offset of sub value
  • size - The size of sub value in bytes

Returns

  • sub_value - The sub value of origin u128

Examples

  • u128_sub_value(0x000001020304, 6, 1, 3) -> 0x000102

Fully qualified path: alexandria_bytes::utils::read_sub_u128

#![allow(unused)]
fn main() {
pub fn read_sub_u128(value: u128, value_size: usize, offset: usize, size: usize) -> u128
}

u128_join

Join two u128 into one.

Arguments

  • left - The left part of u128
  • right - The right part of u128
  • right_size - The size of right part in bytes

Returns

  • value - The joined u128

Examples

  • u128_join(0x010203, 0xaabb, 2) -> 0x010203aabb
  • u128_join(0x010203, 0, 2) -> 0x0102030000

Fully qualified path: alexandria_bytes::utils::u128_join

#![allow(unused)]
fn main() {
pub fn u128_join(left: u128, right: u128, right_size: usize) -> u128
}

pad_left_data

Pads each u128 value in the given array with zeros on the left if its byte size is smaller than bytes_per_element.

Arguments

  • data - An array of u128 values that may require padding.
  • bytes_per_element - The target byte size for each element in the array.

Returns

  • A new Array<u128> where each element is either unchanged (if already bytes_per_element bytes) or padded with zeros.

Padding Strategy

If the byte size of value is less than bytes_per_element, zeros are added to the left using u128_join.

Fully qualified path: alexandria_bytes::utils::pad_left_data

#![allow(unused)]
fn main() {
pub fn pad_left_data(data: Array<u128>, bytes_per_element: usize) -> Array<u128>
}

Structs

Bytes

Note that: In Bytes, there are many variables about size and length.We use size to represent the number of bytes in Bytes.We use length to represent the number of elements in Bytes.Bytes is a cairo implementation of solidity Bytes in Big-endian.It is a dynamic array of u128, where each element contains 16 bytes.To save cost, the last element MUST be filled fully.That means that every element should and MUST contain 16 bytes.For example, if we have a Bytes with 33 bytes, we will have 3 elements.Theoretically, the bytes look like this:first element: [16 bytes](16 bytes)second element: [16 bytes](16 bytes)third element: [1 byte](1 byte)But in alexandria bytes, the last element should be padded with zero to makeit 16 bytes. So the alexandria bytes look like this:first element: [16 bytes](16 bytes)second element: [16 bytes](16 bytes)third element: [1 byte](1 byte) + [15 bytes zero padding](15 bytes zero padding)Bytes is a dynamic array of u128, where each element contains 16 bytes.size: the number of bytes in the Bytesdata: the data of the Bytes

Fully qualified path: alexandria_bytes::bytes::Bytes

#![allow(unused)]
fn main() {
#[derive(Drop, Clone, PartialEq)]
pub struct Bytes {
    size: usize,
    data: Array<u128>,
}
}

BitArray

Fully qualified path: alexandria_bytes::bit_array::BitArray

#![allow(unused)]
fn main() {
#[derive(Clone, Drop)]
pub struct BitArray {
    data: Array<bytes31>,
    current: felt252,
    read_pos: usize,
    write_pos: usize,
}
}

ByteReaderState

Fully qualified path: alexandria_bytes::byte_reader::ByteReaderState

#![allow(unused)]
fn main() {
#[derive(Clone, Drop)]
pub struct ByteReaderState<T> {
    pub(crate) data: @T,
    index: usize,
}
}

Traits

BytesTrait

Fully qualified path: alexandria_bytes::bytes::BytesTrait

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

Trait functions

new

Create a Bytes from an array of u128

Fully qualified path: alexandria_bytes::bytes::BytesTrait::new

#![allow(unused)]
fn main() {
fn new(size: usize, data: Array<u128>) -> Bytes
}

new_empty

Create an empty Bytes

Fully qualified path: alexandria_bytes::bytes::BytesTrait::new_empty

#![allow(unused)]
fn main() {
fn new_empty() -> Bytes
}

zero

Create a Bytes with size bytes 0

Fully qualified path: alexandria_bytes::bytes::BytesTrait::zero

#![allow(unused)]
fn main() {
fn zero(size: usize) -> Bytes
}

locate

Locate offset in Bytes

Fully qualified path: alexandria_bytes::bytes::BytesTrait::locate

#![allow(unused)]
fn main() {
fn locate(offset: usize) -> (usize, usize)
}

size

Get Bytes size

Fully qualified path: alexandria_bytes::bytes::BytesTrait::size

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

data

Get data

Fully qualified path: alexandria_bytes::bytes::BytesTrait::data

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

update_at

update specific value (1 bytes) at specific offset

Fully qualified path: alexandria_bytes::bytes::BytesTrait::update_at

#![allow(unused)]
fn main() {
fn update_at(ref self: Bytes, offset: usize, value: u8)
}

read_u128_packed

Read value with size bytes from Bytes, and packed into u128

Fully qualified path: alexandria_bytes::bytes::BytesTrait::read_u128_packed

#![allow(unused)]
fn main() {
fn read_u128_packed(self: @Bytes, offset: usize, size: usize) -> (usize, u128)
}

read_u128_array_packed

Read value with element_size bytes from Bytes, and packed into u128 array

Fully qualified path: alexandria_bytes::bytes::BytesTrait::read_u128_array_packed

#![allow(unused)]
fn main() {
fn read_u128_array_packed(
    self: @Bytes, offset: usize, array_length: usize, element_size: usize,
) -> (usize, Array<u128>)
}

read_felt252_packed

Read value with size bytes from Bytes, and packed into felt252

Fully qualified path: alexandria_bytes::bytes::BytesTrait::read_felt252_packed

#![allow(unused)]
fn main() {
fn read_felt252_packed(self: @Bytes, offset: usize, size: usize) -> (usize, felt252)
}

read_u8

Read a u8 from Bytes

Fully qualified path: alexandria_bytes::bytes::BytesTrait::read_u8

#![allow(unused)]
fn main() {
fn read_u8(self: @Bytes, offset: usize) -> (usize, u8)
}

read_u16

Read a u16 from Bytes

Fully qualified path: alexandria_bytes::bytes::BytesTrait::read_u16

#![allow(unused)]
fn main() {
fn read_u16(self: @Bytes, offset: usize) -> (usize, u16)
}

read_u32

Read a u32 from Bytes

Fully qualified path: alexandria_bytes::bytes::BytesTrait::read_u32

#![allow(unused)]
fn main() {
fn read_u32(self: @Bytes, offset: usize) -> (usize, u32)
}

read_usize

Read a usize from Bytes

Fully qualified path: alexandria_bytes::bytes::BytesTrait::read_usize

#![allow(unused)]
fn main() {
fn read_usize(self: @Bytes, offset: usize) -> (usize, usize)
}

read_u64

Read a u64 from Bytes

Fully qualified path: alexandria_bytes::bytes::BytesTrait::read_u64

#![allow(unused)]
fn main() {
fn read_u64(self: @Bytes, offset: usize) -> (usize, u64)
}

read_u128

Read a u128 from Bytes

Fully qualified path: alexandria_bytes::bytes::BytesTrait::read_u128

#![allow(unused)]
fn main() {
fn read_u128(self: @Bytes, offset: usize) -> (usize, u128)
}

read_u256

Read a u256 from Bytes

Fully qualified path: alexandria_bytes::bytes::BytesTrait::read_u256

#![allow(unused)]
fn main() {
fn read_u256(self: @Bytes, offset: usize) -> (usize, u256)
}

read_u256_array

Read a u256 array from Bytes

Fully qualified path: alexandria_bytes::bytes::BytesTrait::read_u256_array

#![allow(unused)]
fn main() {
fn read_u256_array(self: @Bytes, offset: usize, array_length: usize) -> (usize, Array<u256>)
}

read_bytes

Read sub Bytes with size bytes from Bytes

Fully qualified path: alexandria_bytes::bytes::BytesTrait::read_bytes

#![allow(unused)]
fn main() {
fn read_bytes(self: @Bytes, offset: usize, size: usize) -> (usize, Bytes)
}

read_felt252

Read felt252 from Bytes, which stored as u256

Fully qualified path: alexandria_bytes::bytes::BytesTrait::read_felt252

#![allow(unused)]
fn main() {
fn read_felt252(self: @Bytes, offset: usize) -> (usize, felt252)
}

read_bytes31

Read bytes31 from Bytes

Fully qualified path: alexandria_bytes::bytes::BytesTrait::read_bytes31

#![allow(unused)]
fn main() {
fn read_bytes31(self: @Bytes, offset: usize) -> (usize, bytes31)
}

read_address

Read a ContractAddress from Bytes

Fully qualified path: alexandria_bytes::bytes::BytesTrait::read_address

#![allow(unused)]
fn main() {
fn read_address(self: @Bytes, offset: usize) -> (usize, ContractAddress)
}

append_u128_packed

Write value with size bytes into Bytes, value is packed into u128

Fully qualified path: alexandria_bytes::bytes::BytesTrait::append_u128_packed

#![allow(unused)]
fn main() {
fn append_u128_packed(ref self: Bytes, value: u128, size: usize)
}

append_u8

Write u8 into Bytes

Fully qualified path: alexandria_bytes::bytes::BytesTrait::append_u8

#![allow(unused)]
fn main() {
fn append_u8(ref self: Bytes, value: u8)
}

append_u16

Write u16 into Bytes

Fully qualified path: alexandria_bytes::bytes::BytesTrait::append_u16

#![allow(unused)]
fn main() {
fn append_u16(ref self: Bytes, value: u16)
}

append_u32

Write u32 into Bytes

Fully qualified path: alexandria_bytes::bytes::BytesTrait::append_u32

#![allow(unused)]
fn main() {
fn append_u32(ref self: Bytes, value: u32)
}

append_usize

Write usize into Bytes

Fully qualified path: alexandria_bytes::bytes::BytesTrait::append_usize

#![allow(unused)]
fn main() {
fn append_usize(ref self: Bytes, value: usize)
}

append_u64

Write u64 into Bytes

Fully qualified path: alexandria_bytes::bytes::BytesTrait::append_u64

#![allow(unused)]
fn main() {
fn append_u64(ref self: Bytes, value: u64)
}

append_u128

Write u128 into Bytes

Fully qualified path: alexandria_bytes::bytes::BytesTrait::append_u128

#![allow(unused)]
fn main() {
fn append_u128(ref self: Bytes, value: u128)
}

append_u256

Write u256 into Bytes

Fully qualified path: alexandria_bytes::bytes::BytesTrait::append_u256

#![allow(unused)]
fn main() {
fn append_u256(ref self: Bytes, value: u256)
}

append_felt252

Write felt252 into Bytes, which stored as u256

Fully qualified path: alexandria_bytes::bytes::BytesTrait::append_felt252

#![allow(unused)]
fn main() {
fn append_felt252(ref self: Bytes, value: felt252)
}

append_bytes31

Write bytes31 into Bytes

Fully qualified path: alexandria_bytes::bytes::BytesTrait::append_bytes31

#![allow(unused)]
fn main() {
fn append_bytes31(ref self: Bytes, value: bytes31)
}

append_address

Write address into Bytes

Fully qualified path: alexandria_bytes::bytes::BytesTrait::append_address

#![allow(unused)]
fn main() {
fn append_address(ref self: Bytes, value: ContractAddress)
}

concat

concat with other Bytes

Fully qualified path: alexandria_bytes::bytes::BytesTrait::concat

#![allow(unused)]
fn main() {
fn concat(ref self: Bytes, other: @Bytes)
}

keccak

keccak hash

Fully qualified path: alexandria_bytes::bytes::BytesTrait::keccak

#![allow(unused)]
fn main() {
fn keccak(self: @Bytes) -> u256
}

sha256

sha256 hash

Fully qualified path: alexandria_bytes::bytes::BytesTrait::sha256

#![allow(unused)]
fn main() {
fn sha256(self: @Bytes) -> u256
}

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)
}

ByteAppenderSupportTrait

Generic support trait for appending signed and unsigned integers onto byte storage. There are two functions, one for each of big and little endian byte order due to performance considerations. The byte reversal could be used in the naïve case when only one implementation is worthwhile.

Fully qualified path: alexandria_bytes::byte_appender::ByteAppenderSupportTrait

#![allow(unused)]
fn main() {
pub trait ByteAppenderSupportTrait<T>
}

Trait functions

append_bytes_be

Appends bytes data of size count ordered in big endian

Arguments

  • bytes - Big endian ordered bytes to append
  • count - Number of bytes from input to append

Fully qualified path: alexandria_bytes::byte_appender::ByteAppenderSupportTrait::append_bytes_be

#![allow(unused)]
fn main() {
fn append_bytes_be(ref self: T, bytes: felt252, count: usize)
}

append_bytes_le

Appends bytes data of size count ordered in little endian

Arguments

  • bytes - Little endian ordered bytes to append
  • count - Number of bytes from input to append

Fully qualified path: alexandria_bytes::byte_appender::ByteAppenderSupportTrait::append_bytes_le

#![allow(unused)]
fn main() {
fn append_bytes_le(ref self: T, bytes: felt252, count: usize)
}

ByteAppender

Fully qualified path: alexandria_bytes::byte_appender::ByteAppender

#![allow(unused)]
fn main() {
pub trait ByteAppender<T>
}

Trait functions

append_u16

Appends an unsigned 16 bit integer encoded in big endian

Arguments

  • word - A 16 bit unsigned integer typed as u16

Fully qualified path: alexandria_bytes::byte_appender::ByteAppender::append_u16

#![allow(unused)]
fn main() {
fn append_u16(ref self: T, word: u16)
}

append_u16_le

Appends an unsigned 16 bit integer encoded in little endian

Arguments

  • word - A 16 bit unsigned integer typed as u16

Fully qualified path: alexandria_bytes::byte_appender::ByteAppender::append_u16_le

#![allow(unused)]
fn main() {
fn append_u16_le(ref self: T, word: u16)
}

append_u32

Appends an unsigned 32 bit integer encoded in big endian

Arguments

  • word - A 32 bit unsigned integer typed as u32

Fully qualified path: alexandria_bytes::byte_appender::ByteAppender::append_u32

#![allow(unused)]
fn main() {
fn append_u32(ref self: T, word: u32)
}

append_u32_le

Appends an unsigned 32 bit integer encoded in little endian

Arguments

  • word - A 32 bit unsigned integer typed as u32

Fully qualified path: alexandria_bytes::byte_appender::ByteAppender::append_u32_le

#![allow(unused)]
fn main() {
fn append_u32_le(ref self: T, word: u32)
}

append_u64

Appends an unsigned 64 bit integer encoded in big endian

Arguments

  • word - A 64 bit unsigned integer typed as u64

Fully qualified path: alexandria_bytes::byte_appender::ByteAppender::append_u64

#![allow(unused)]
fn main() {
fn append_u64(ref self: T, word: u64)
}

append_u64_le

Appends an unsigned 64 bit integer encoded in little endian

Arguments

  • word - A 64 bit unsigned integer typed as u64

Fully qualified path: alexandria_bytes::byte_appender::ByteAppender::append_u64_le

#![allow(unused)]
fn main() {
fn append_u64_le(ref self: T, word: u64)
}

append_u128

Appends an unsigned 128 bit integer encoded in big endian

Arguments

  • word - A 128 bit unsigned integer typed as u128

Fully qualified path: alexandria_bytes::byte_appender::ByteAppender::append_u128

#![allow(unused)]
fn main() {
fn append_u128(ref self: T, word: u128)
}

append_u128_le

Appends an unsigned 128 bit integer encoded in little endian

Arguments

  • word - A 128 bit unsigned integer typed as u128

Fully qualified path: alexandria_bytes::byte_appender::ByteAppender::append_u128_le

#![allow(unused)]
fn main() {
fn append_u128_le(ref self: T, word: u128)
}

append_u256

Appends an unsigned 256 bit integer encoded in big endian

Arguments

  • word - A 256 bit unsigned integer typed as u256

Fully qualified path: alexandria_bytes::byte_appender::ByteAppender::append_u256

#![allow(unused)]
fn main() {
fn append_u256(ref self: T, word: u256)
}

append_u256_le

Appends an unsigned 256 bit integer encoded in little endian

Arguments

  • word - A 256 bit unsigned integer typed as u256

Fully qualified path: alexandria_bytes::byte_appender::ByteAppender::append_u256_le

#![allow(unused)]
fn main() {
fn append_u256_le(ref self: T, word: u256)
}

append_u512

Appends an unsigned 512 bit integer encoded in big endian

Arguments

  • word - A 512 bit unsigned integer typed as u32

Fully qualified path: alexandria_bytes::byte_appender::ByteAppender::append_u512

#![allow(unused)]
fn main() {
fn append_u512(ref self: T, word: u512)
}

append_u512_le

Appends an unsigned 512 bit integer encoded in little endian

Arguments

  • word - A 512 bit unsigned integer typed as u32

Fully qualified path: alexandria_bytes::byte_appender::ByteAppender::append_u512_le

#![allow(unused)]
fn main() {
fn append_u512_le(ref self: T, word: u512)
}

append_i8

Appends a signed 8 bit integer

Arguments

  • word - An 8 bit signed integer typed as i8

Fully qualified path: alexandria_bytes::byte_appender::ByteAppender::append_i8

#![allow(unused)]
fn main() {
fn append_i8(ref self: T, word: i8)
}

append_i16

Appends a signed 16 bit integer encoded in big endian

Arguments

  • word - A 16 bit signed integer typed as i16

Fully qualified path: alexandria_bytes::byte_appender::ByteAppender::append_i16

#![allow(unused)]
fn main() {
fn append_i16(ref self: T, word: i16)
}

append_i16_le

Appends a signed 16 bit integer encoded in little endian

Arguments

  • word - A 16 bit signed integer typed as i16

Fully qualified path: alexandria_bytes::byte_appender::ByteAppender::append_i16_le

#![allow(unused)]
fn main() {
fn append_i16_le(ref self: T, word: i16)
}

append_i32

Appends a signed 32 bit integer encoded in big endian

Arguments

  • word - A 32 bit signed integer typed as i32

Fully qualified path: alexandria_bytes::byte_appender::ByteAppender::append_i32

#![allow(unused)]
fn main() {
fn append_i32(ref self: T, word: i32)
}

append_i32_le

Appends a signed 32 bit integer encoded in little endian

Arguments

  • word - A 32 bit signed integer typed as i32

Fully qualified path: alexandria_bytes::byte_appender::ByteAppender::append_i32_le

#![allow(unused)]
fn main() {
fn append_i32_le(ref self: T, word: i32)
}

append_i64

Appends a signed 64 bit integer encoded in big endian

Arguments

  • word - A 64 bit signed integer typed as i64

Fully qualified path: alexandria_bytes::byte_appender::ByteAppender::append_i64

#![allow(unused)]
fn main() {
fn append_i64(ref self: T, word: i64)
}

append_i64_le

Appends a signed 64 bit integer encoded in little endian

Arguments

  • word - A 64 bit signed integer typed as i64

Fully qualified path: alexandria_bytes::byte_appender::ByteAppender::append_i64_le

#![allow(unused)]
fn main() {
fn append_i64_le(ref self: T, word: i64)
}

append_i128

Appends a signed 128 bit integer encoded in big endian

Arguments

  • word - A 128 bit signed integer typed as i128

Fully qualified path: alexandria_bytes::byte_appender::ByteAppender::append_i128

#![allow(unused)]
fn main() {
fn append_i128(ref self: T, word: i128)
}

append_i128_le

Appends a signed 128 bit integer encoded in little endian

Arguments

  • word - A 128 bit signed integer typed as i128

Fully qualified path: alexandria_bytes::byte_appender::ByteAppender::append_i128_le

#![allow(unused)]
fn main() {
fn append_i128_le(ref self: T, word: i128)
}

ByteArrayTraitExt

Extension trait for reading and writing different data types to ByteArray

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt

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

Trait functions

new

Create a ByteArray from an array of u128

Arguments

  • size - The size of the ByteArray
  • data - Array of u128 values to create ByteArray from

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::new

#![allow(unused)]
fn main() {
fn new(size: usize, data: Array<u128>) -> ByteArray
}

new_empty

Instantiate a new ByteArray

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::new_empty

#![allow(unused)]
fn main() {
fn new_empty() -> ByteArray
}

size

Get the size of the ByteArray

Arguments

  • self - The ByteArray to get the size of

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::size

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

read_u8

Reads a 8-bit unsigned integer from the given offset.

Arguments

  • self - The ByteArray to read from
  • offset - The offset to read from

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::read_u8

#![allow(unused)]
fn main() {
fn read_u8(self: @ByteArray, offset: usize) -> (usize, u8)
}

read_u16

Reads a 16-bit unsigned integer from the given offset.

Arguments

  • self - The ByteArray to read from
  • offset - The offset to read from

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::read_u16

#![allow(unused)]
fn main() {
fn read_u16(self: @ByteArray, offset: usize) -> (usize, u16)
}

read_u32

Reads a 32-bit unsigned integer from the given offset.

Arguments

  • self - The ByteArray to read from
  • offset - The offset to read from

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::read_u32

#![allow(unused)]
fn main() {
fn read_u32(self: @ByteArray, offset: usize) -> (usize, u32)
}

read_usize

Reads a usize from the given offset.

Arguments

  • self - The ByteArray to read from
  • offset - The offset to read from

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::read_usize

#![allow(unused)]
fn main() {
fn read_usize(self: @ByteArray, offset: usize) -> (usize, usize)
}

read_u64

Reads a 64-bit unsigned integer from the given offset.

Arguments

  • self - The ByteArray to read from
  • offset - The offset to read from

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::read_u64

#![allow(unused)]
fn main() {
fn read_u64(self: @ByteArray, offset: usize) -> (usize, u64)
}

read_u128

Reads a 128-bit unsigned integer from the given offset.

Arguments

  • self - The ByteArray to read from
  • offset - The offset to read from

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::read_u128

#![allow(unused)]
fn main() {
fn read_u128(self: @ByteArray, offset: usize) -> (usize, u128)
}

read_u128_packed

Read value with size bytes from ByteArray, and packed into u128

Arguments

  • self - The ByteArray to read from
  • offset - The offset to read from
  • size - The number of bytes to read

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::read_u128_packed

#![allow(unused)]
fn main() {
fn read_u128_packed(self: @ByteArray, offset: usize, size: usize) -> (usize, u128)
}

read_u128_array_packed

Reads a packed array of u128 values from the given offset.

Arguments

  • self - The ByteArray to read from
  • offset - The offset to read from
  • array_length - The length of the array to read
  • element_size - The size of each element in bytes

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::read_u128_array_packed

#![allow(unused)]
fn main() {
fn read_u128_array_packed(
    self: @ByteArray, offset: usize, array_length: usize, element_size: usize,
) -> (usize, Array<u128>)
}

read_u256

Reads a 256-bit unsigned integer from the given offset.

Arguments

  • self - The ByteArray to read from
  • offset - The offset to read from

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::read_u256

#![allow(unused)]
fn main() {
fn read_u256(self: @ByteArray, offset: usize) -> (usize, u256)
}

read_u256_array

Reads an array of u256 values from the given offset.

Arguments

  • self - The ByteArray to read from
  • offset - The offset to read from
  • array_length - The length of the array to read

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::read_u256_array

#![allow(unused)]
fn main() {
fn read_u256_array(self: @ByteArray, offset: usize, array_length: usize) -> (usize, Array<u256>)
}

read_felt252

Reads a felt252 (Starknet field element) from the given offset.

Arguments

  • self - The ByteArray to read from
  • offset - The offset to read from

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::read_felt252

#![allow(unused)]
fn main() {
fn read_felt252(self: @ByteArray, offset: usize) -> (usize, felt252)
}

read_felt252_packed

Read value with size bytes from Bytes, and packed into felt252

Arguments

  • self - The ByteArray to read from
  • offset - The offset to read from
  • size - The number of bytes to read

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::read_felt252_packed

#![allow(unused)]
fn main() {
fn read_felt252_packed(self: @ByteArray, offset: usize, size: usize) -> (usize, felt252)
}

read_bytes31

Reads a bytes31 value (31-byte sequence) from the given offset.

Arguments

  • self - The ByteArray to read from
  • offset - The offset to read from

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::read_bytes31

#![allow(unused)]
fn main() {
fn read_bytes31(self: @ByteArray, offset: usize) -> (usize, bytes31)
}

read_address

Reads a Starknet contract address from the given offset.

Arguments

  • self - The ByteArray to read from
  • offset - The offset to read from

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::read_address

#![allow(unused)]
fn main() {
fn read_address(self: @ByteArray, offset: usize) -> (usize, ContractAddress)
}

read_bytes

Reads a raw sequence of bytes of given size from the given offset.

Arguments

  • self - The ByteArray to read from
  • offset - The offset to read from
  • size - The number of bytes to read

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::read_bytes

#![allow(unused)]
fn main() {
fn read_bytes(self: @ByteArray, offset: usize, size: usize) -> (usize, ByteArray)
}

append_u8

Appends a 8-bit unsigned integer to the ByteArray.

Arguments

  • self - The ByteArray to append to
  • value - The value to append

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::append_u8

#![allow(unused)]
fn main() {
fn append_u8(ref self: ByteArray, value: u8)
}

append_u16

Appends a 16-bit unsigned integer to the ByteArray.

Arguments

  • self - The ByteArray to append to
  • value - The value to append

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::append_u16

#![allow(unused)]
fn main() {
fn append_u16(ref self: ByteArray, value: u16)
}

append_u32

Appends a 32-bit unsigned integer to the ByteArray.

Arguments

  • self - The ByteArray to append to
  • value - The value to append

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::append_u32

#![allow(unused)]
fn main() {
fn append_u32(ref self: ByteArray, value: u32)
}

append_usize

Appends usize to the ByteArray.

Arguments

  • self - The ByteArray to append to
  • value - The value to append

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::append_usize

#![allow(unused)]
fn main() {
fn append_usize(ref self: ByteArray, value: usize)
}

append_u64

Appends a 64-bit unsigned integer to the ByteArray.

Arguments

  • self - The ByteArray to append to
  • value - The value to append

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::append_u64

#![allow(unused)]
fn main() {
fn append_u64(ref self: ByteArray, value: u64)
}

append_u128

Appends a 128-bit unsigned integer to the ByteArray.

Arguments

  • self - The ByteArray to append to
  • value - The value to append

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::append_u128

#![allow(unused)]
fn main() {
fn append_u128(ref self: ByteArray, value: u128)
}

append_u256

Appends a 256-bit unsigned integer to the ByteArray.

Arguments

  • self - The ByteArray to append to
  • value - The value to append

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::append_u256

#![allow(unused)]
fn main() {
fn append_u256(ref self: ByteArray, value: u256)
}

append_u512

Appends a 512-bit unsigned integer to the ByteArray.

Arguments

  • self - The ByteArray to append to
  • value - The value to append

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::append_u512

#![allow(unused)]
fn main() {
fn append_u512(ref self: ByteArray, value: u512)
}

append_felt252

Appends a felt252 to the ByteArray.

Arguments

  • self - The ByteArray to append to
  • value - The value to append

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::append_felt252

#![allow(unused)]
fn main() {
fn append_felt252(ref self: ByteArray, value: felt252)
}

append_address

Appends a Starknet contract address to the ByteArray.

Arguments

  • self - The ByteArray to append to
  • value - The value to append

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::append_address

#![allow(unused)]
fn main() {
fn append_address(ref self: ByteArray, value: ContractAddress)
}

append_bytes31

Appends a bytes31 value to the ByteArray.

Arguments

  • self - The ByteArray to append to
  • value - The value to append

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::append_bytes31

#![allow(unused)]
fn main() {
fn append_bytes31(ref self: ByteArray, value: bytes31)
}

update_at

Updates a byte at the given offset with a new value.

Arguments

  • self - The ByteArray to update
  • offset - The offset to update at
  • value - The new value

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::update_at

#![allow(unused)]
fn main() {
fn update_at(ref self: ByteArray, offset: usize, value: u8)
}

read_uint_within_size

Reads an unsigned integer of type T from the ByteArray starting at a given offset, with a specified size.

Arguments

  • self - The ByteArray to read from
  • offset - The offset to read from
  • size - The number of bytes to read

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExt::read_uint_within_size

#![allow(unused)]
fn main() {
fn read_uint_within_size<
    T, +Add<T>, +Mul<T>, +Zero<T>, +TryInto<felt252, T>, +Drop<T>, +Into<u8, T>,
>(
    self: @ByteArray, offset: usize, size: usize,
) -> (usize, T)
}

ByteReader

Fully qualified path: alexandria_bytes::byte_reader::ByteReader

#![allow(unused)]
fn main() {
pub trait ByteReader<T>
}

Trait functions

reader

Wraps the array of bytes in a ByteReader for sequential consumption of integers and/or bytes

Returns

  • ByteReader - The reader struct wrapping a read-only snapshot of this ByteArray

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::reader

#![allow(unused)]
fn main() {
fn reader(self: @T) -> ByteReaderState<T>
}

remaining

Checks that there are enough remaining bytes available

Arguments

  • at - The start index position of the byte data
  • count - the number of bytes required

Returns

  • bool - true when there are count bytes remaining, false otherwise.

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::remaining

#![allow(unused)]
fn main() {
fn remaining(self: @T, at: usize, count: usize) -> bool
}

word_u16

Reads consecutive bytes from a specified offset as an unsigned integer in big endian

Arguments

  • offset - The start location of the consecutive bytes to read

Returns

  • Option<u16> - Returns an integer if there are enough consecutive bytes available in the ByteArray

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::word_u16

#![allow(unused)]
fn main() {
fn word_u16(self: @T, offset: usize) -> Option<u16>
}

word_u16_le

Reads consecutive bytes from a specified offset as an unsigned integer in little endian

Arguments

  • offset - The start location of the consecutive bytes to read

Returns

  • Option<u16> - Returns an integer if there are enough consecutive bytes available in the ByteArray

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::word_u16_le

#![allow(unused)]
fn main() {
fn word_u16_le(self: @T, offset: usize) -> Option<u16>
}

word_u32

Reads consecutive bytes from a specified offset as an unsigned integer in big endian

Arguments

  • offset - The start location of the consecutive bytes to read

Returns

  • Option<u32> - Returns an integer if there are enough consecutive bytes available in the ByteArray

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::word_u32

#![allow(unused)]
fn main() {
fn word_u32(self: @T, offset: usize) -> Option<u32>
}

word_u32_le

Reads consecutive bytes from a specified offset as an unsigned integer in little endian

Arguments

  • offset - The start location of the consecutive bytes to read

Returns

  • Option<u32> - Returns an integer if there are enough consecutive bytes available in the ByteArray

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::word_u32_le

#![allow(unused)]
fn main() {
fn word_u32_le(self: @T, offset: usize) -> Option<u32>
}

word_u64

Reads consecutive bytes from a specified offset as an unsigned integer in big endian

Arguments

  • offset - The start location of the consecutive bytes to read

Returns

  • Option<u64> - Returns an integer if there are enough consecutive bytes available in the ByteArray

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::word_u64

#![allow(unused)]
fn main() {
fn word_u64(self: @T, offset: usize) -> Option<u64>
}

word_u64_le

Reads consecutive bytes from a specified offset as an unsigned integer in little endian

Arguments

  • offset - The start location of the consecutive bytes to read

Returns

  • Option<u64> - Returns an integer if there are enough consecutive bytes available in the ByteArray

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::word_u64_le

#![allow(unused)]
fn main() {
fn word_u64_le(self: @T, offset: usize) -> Option<u64>
}

word_u128

Reads consecutive bytes from a specified offset as an unsigned integer in big endian

Arguments

  • offset - The start location of the consecutive bytes to read

Returns

  • Option<u128> - Returns an integer if there are enough consecutive bytes available in the ByteArray

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::word_u128

#![allow(unused)]
fn main() {
fn word_u128(self: @T, offset: usize) -> Option<u128>
}

word_u128_le

Reads consecutive bytes from a specified offset as an unsigned integer in little endian

Arguments

  • offset - The start location of the consecutive bytes to read

Returns

  • Option<u128> - Returns an integer if there are enough consecutive bytes available in the ByteArray

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::word_u128_le

#![allow(unused)]
fn main() {
fn word_u128_le(self: @T, offset: usize) -> Option<u128>
}

read_u8

Reads a u8 unsigned integer

Returns

  • Option<u8> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::read_u8

#![allow(unused)]
fn main() {
fn read_u8(ref self: ByteReaderState<T>) -> Option<u8>
}

read_u16

Reads a u16 unsigned integer in big endian byte order

Returns

  • Option<u16> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::read_u16

#![allow(unused)]
fn main() {
fn read_u16(ref self: ByteReaderState<T>) -> Option<u16>
}

read_u16_le

Reads a u16 unsigned integer in little endian byte order

Returns

  • Option<u16> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::read_u16_le

#![allow(unused)]
fn main() {
fn read_u16_le(ref self: ByteReaderState<T>) -> Option<u16>
}

read_u32

Reads a u32 unsigned integer in big endian byte order

Returns

  • Option<u32> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::read_u32

#![allow(unused)]
fn main() {
fn read_u32(ref self: ByteReaderState<T>) -> Option<u32>
}

read_u32_le

Reads a u32 unsigned integer in little endian byte order

Returns

  • Option<u32> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::read_u32_le

#![allow(unused)]
fn main() {
fn read_u32_le(ref self: ByteReaderState<T>) -> Option<u32>
}

read_u64

Reads a u64 unsigned integer in big endian byte order

Returns

  • Option<u64> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::read_u64

#![allow(unused)]
fn main() {
fn read_u64(ref self: ByteReaderState<T>) -> Option<u64>
}

read_u64_le

Reads a u64 unsigned integer in little endian byte order

Returns

  • Option<u64> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::read_u64_le

#![allow(unused)]
fn main() {
fn read_u64_le(ref self: ByteReaderState<T>) -> Option<u64>
}

read_u128

Reads a u128 unsigned integer in big endian byte order

Returns

  • Option<u218> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::read_u128

#![allow(unused)]
fn main() {
fn read_u128(ref self: ByteReaderState<T>) -> Option<u128>
}

read_u128_le

Reads a u128 unsigned integer in little endian byte order

Returns

  • Option<u218> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::read_u128_le

#![allow(unused)]
fn main() {
fn read_u128_le(ref self: ByteReaderState<T>) -> Option<u128>
}

read_u256

Reads a u256 unsigned integer in big endian byte order

Returns

  • Option<u256> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::read_u256

#![allow(unused)]
fn main() {
fn read_u256(ref self: ByteReaderState<T>) -> Option<u256>
}

read_u256_le

Reads a u256 unsigned integer in little endian byte order

Returns

  • Option<u256> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::read_u256_le

#![allow(unused)]
fn main() {
fn read_u256_le(ref self: ByteReaderState<T>) -> Option<u256>
}

read_u512

Reads a u512 unsigned integer in big endian byte order

Returns

  • Option<u512> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::read_u512

#![allow(unused)]
fn main() {
fn read_u512(ref self: ByteReaderState<T>) -> Option<u512>
}

read_u512_le

Reads a u512 unsigned integer in little endian byte order

Returns

  • Option<u512> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::read_u512_le

#![allow(unused)]
fn main() {
fn read_u512_le(ref self: ByteReaderState<T>) -> Option<u512>
}

read_i8

Reads an i8 signed integer in two's complement encoding from the ByteArray

Returns

  • Option<i8> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::read_i8

#![allow(unused)]
fn main() {
fn read_i8(ref self: ByteReaderState<T>) -> Option<i8>
}

read_i16

Reads an i16 signed integer in two's complement encoding from the ByteArray in big endian byte order

Returns

  • Option<i16> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::read_i16

#![allow(unused)]
fn main() {
fn read_i16(ref self: ByteReaderState<T>) -> Option<i16>
}

read_i16_le

Reads an i16 signed integer in two's complement encoding from the ByteArray in little endian byte order

Returns

  • Option<i16> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::read_i16_le

#![allow(unused)]
fn main() {
fn read_i16_le(ref self: ByteReaderState<T>) -> Option<i16>
}

read_i32

Reads an i32 signed integer in two's complement encoding from the ByteArray in big endian byte order

Returns

  • Option<i32> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::read_i32

#![allow(unused)]
fn main() {
fn read_i32(ref self: ByteReaderState<T>) -> Option<i32>
}

read_i32_le

Reads an i32 signed integer in two's complement encoding from the ByteArray in little endian byte order

Returns

  • Option<i32> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::read_i32_le

#![allow(unused)]
fn main() {
fn read_i32_le(ref self: ByteReaderState<T>) -> Option<i32>
}

read_i64

Reads an i64 signed integer in two's complement encoding from the ByteArray in big endian byte order

Returns

  • Option<i64> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::read_i64

#![allow(unused)]
fn main() {
fn read_i64(ref self: ByteReaderState<T>) -> Option<i64>
}

read_i64_le

Reads an i64 signed integer in two's complement encoding from the ByteArray in little endian byte order

Returns

  • Option<i64> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::read_i64_le

#![allow(unused)]
fn main() {
fn read_i64_le(ref self: ByteReaderState<T>) -> Option<i64>
}

read_i128

Reads an i128 signed integer in two's complement encoding from the ByteArray in big endian byte order

Returns

  • Option<i128> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::read_i128

#![allow(unused)]
fn main() {
fn read_i128(ref self: ByteReaderState<T>) -> Option<i128>
}

read_i128_le

Reads an i128 signed integer in two's complement encoding from the ByteArray in little endian byte order

Returns

  • Option<i128> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::read_i128_le

#![allow(unused)]
fn main() {
fn read_i128_le(ref self: ByteReaderState<T>) -> Option<i128>
}

len

Remaining length count relative to what has already been consume/read

Returns

  • usize - count number of bytes remaining

Fully qualified path: alexandria_bytes::byte_reader::ByteReader::len

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

ReversibleBytes

Implies that there is an underlying byte order for type T that can be reversed

Fully qualified path: alexandria_bytes::reversible::ReversibleBytes

#![allow(unused)]
fn main() {
pub trait ReversibleBytes<T>
}

Trait functions

reverse_bytes

Reverses the byte order or endianness of self. For example, the word 0x1122_u16 is reversed into 0x2211_u16.

Returns

  • T - Returns the byte reversal of self into the same type T

Fully qualified path: alexandria_bytes::reversible::ReversibleBytes::reverse_bytes

#![allow(unused)]
fn main() {
fn reverse_bytes(self: @T) -> T
}

ReversibleBits

Implies that there is an underlying bit order for type T that can be reversed

Fully qualified path: alexandria_bytes::reversible::ReversibleBits

#![allow(unused)]
fn main() {
pub trait ReversibleBits<T>
}

Trait functions

reverse_bits

Reverses the underlying ordering of the bit representation of self. For example, the word 0b10111010_u8 is reversed into 0b01011101.

Returns

  • T - the bit-representation of self reversed into the same type T

Fully qualified path: alexandria_bytes::reversible::ReversibleBits::reverse_bits

#![allow(unused)]
fn main() {
fn reverse_bits(self: @T) -> T
}

Impls

BytesIndex

Fully qualified path: alexandria_bytes::bytes::BytesIndex

#![allow(unused)]
fn main() {
pub impl BytesIndex of IndexView<Bytes, usize>
}

Impl functions

index

Fully qualified path: alexandria_bytes::bytes::BytesIndex::index

#![allow(unused)]
fn main() {
fn index(self: @Bytes, index: usize) -> @u128
}

Impl types

Target

Fully qualified path: alexandria_bytes::bytes::BytesIndex::Target

#![allow(unused)]
fn main() {
type Target = @u128;
}

BytesStore

Store for a Bytes object.The layout of a Bytes object in storage is as follows: * Only the size in bytes is stored in the original address where the bytes object is stored. * The actual data is stored in chunks of 256 u128 values in another location in storage determined by the hash of: - The address storing the size of the bytes object. - The chunk index. - The short string Bytes.

Fully qualified path: alexandria_bytes::storage::BytesStore

#![allow(unused)]
fn main() {
pub impl BytesStore of Store<Bytes>
}

Impl functions

read

Fully qualified path: alexandria_bytes::storage::BytesStore::read

#![allow(unused)]
fn main() {
fn read(address_domain: u32, base: StorageBaseAddress) -> SyscallResult<Bytes>
}

write

Fully qualified path: alexandria_bytes::storage::BytesStore::write

#![allow(unused)]
fn main() {
fn write(address_domain: u32, base: StorageBaseAddress, value: Bytes) -> SyscallResult<()>
}

read_at_offset

Fully qualified path: alexandria_bytes::storage::BytesStore::read_at_offset

#![allow(unused)]
fn main() {
fn read_at_offset(address_domain: u32, base: StorageBaseAddress, offset: u8) -> SyscallResult<Bytes>
}

write_at_offset

Fully qualified path: alexandria_bytes::storage::BytesStore::write_at_offset

#![allow(unused)]
fn main() {
fn write_at_offset(
    address_domain: u32, base: StorageBaseAddress, offset: u8, value: Bytes,
) -> SyscallResult<()>
}

size

Fully qualified path: alexandria_bytes::storage::BytesStore::size

#![allow(unused)]
fn main() {
fn size() -> u8
}

SpanU8IntoBytearray

Fully qualified path: alexandria_bytes::byte_array_ext::SpanU8IntoBytearray

#![allow(unused)]
fn main() {
pub impl SpanU8IntoBytearray of Into<Span<u8>, ByteArray>
}

Impl functions

into

Fully qualified path: alexandria_bytes::byte_array_ext::SpanU8IntoBytearray::into

#![allow(unused)]
fn main() {
fn into(self: Span<u8>) -> ByteArray
}

ByteArrayIntoArrayU8

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayIntoArrayU8

#![allow(unused)]
fn main() {
pub impl ByteArrayIntoArrayU8 of Into<ByteArray, Array<u8>>
}

Impl functions

into

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayIntoArrayU8::into

#![allow(unused)]
fn main() {
fn into(self: ByteArray) -> Array<u8>
}

ByteArrayTraitExtImpl

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl

#![allow(unused)]
fn main() {
pub impl ByteArrayTraitExtImpl of ByteArrayTraitExt
}

Impl functions

new

Create a ByteArray from an array of u128

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::new

#![allow(unused)]
fn main() {
fn new(size: usize, mut data: Array<u128>) -> ByteArray
}

new_empty

instantiate a new ByteArray

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::new_empty

#![allow(unused)]
fn main() {
fn new_empty() -> ByteArray
}

size

get size. Same as len()

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::size

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

read_u8

Read a u_ from ByteArray

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::read_u8

#![allow(unused)]
fn main() {
fn read_u8(self: @ByteArray, offset: usize) -> (usize, u8)
}

read_u16

Read a u16 from ByteArray

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::read_u16

#![allow(unused)]
fn main() {
fn read_u16(self: @ByteArray, offset: usize) -> (usize, u16)
}

read_u32

Read a u32 from ByteArray

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::read_u32

#![allow(unused)]
fn main() {
fn read_u32(self: @ByteArray, offset: usize) -> (usize, u32)
}

read_usize

Read a usize from ByteArray

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::read_usize

#![allow(unused)]
fn main() {
fn read_usize(self: @ByteArray, offset: usize) -> (usize, usize)
}

read_u64

Read a u64 from ByteArray

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::read_u64

#![allow(unused)]
fn main() {
fn read_u64(self: @ByteArray, offset: usize) -> (usize, u64)
}

read_u128

Read a u128 from ByteArray

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::read_u128

#![allow(unused)]
fn main() {
fn read_u128(self: @ByteArray, offset: usize) -> (usize, u128)
}

read_u128_packed

Read value with size bytes from ByteArray, and packed into u128 Arguments: - offset: the offset in Bytes - size: the number of bytes to read Returns: - new_offset: next value offset in Bytes - value: the value packed into u128

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::read_u128_packed

#![allow(unused)]
fn main() {
fn read_u128_packed(self: @ByteArray, offset: usize, size: usize) -> (usize, u128)
}

read_u256

Read a u256 from ByteArray

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::read_u256

#![allow(unused)]
fn main() {
fn read_u256(self: @ByteArray, offset: usize) -> (usize, u256)
}

read_felt252_packed

Read value with size bytes from ByteArray, and packed into felt252 Arguments: - offset: the offset in Bytes - size: the number of bytes to read Returns: - new_offset: next value offset in Bytes - value: the value packed into felt252

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::read_felt252_packed

#![allow(unused)]
fn main() {
fn read_felt252_packed(self: @ByteArray, offset: usize, size: usize) -> (usize, felt252)
}

read_felt252

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::read_felt252

#![allow(unused)]
fn main() {
fn read_felt252(self: @ByteArray, offset: usize) -> (usize, felt252)
}

read_bytes31

Read a bytes31 from ByteArray

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::read_bytes31

#![allow(unused)]
fn main() {
fn read_bytes31(self: @ByteArray, offset: usize) -> (usize, bytes31)
}

read_address

Read Contract Address from Bytes

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::read_address

#![allow(unused)]
fn main() {
fn read_address(self: @ByteArray, offset: usize) -> (usize, ContractAddress)
}

read_bytes

Read bytes from ByteArray

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::read_bytes

#![allow(unused)]
fn main() {
fn read_bytes(self: @ByteArray, offset: usize, size: usize) -> (usize, ByteArray)
}

read_u128_array_packed

Read an array of u128 values from ByteArray

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::read_u128_array_packed

#![allow(unused)]
fn main() {
fn read_u128_array_packed(
    self: @ByteArray, offset: usize, array_length: usize, element_size: usize,
) -> (usize, Array<u128>)
}

read_u256_array

Read an array of u256 values from ByteArray

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::read_u256_array

#![allow(unused)]
fn main() {
fn read_u256_array(self: @ByteArray, offset: usize, array_length: usize) -> (usize, Array<u256>)
}

read_uint_within_size

Reads an unsigned integer of type T from the ByteArray starting at a given offset, with a specified size.Inputs: - self: A reference to the ByteArray from which to read. - offset: The starting position in the ByteArray to begin reading. - size: The number of bytes to read.Outputs: - A tuple containing: - The new offset after reading the specified number of bytes. - The value of type T read from the ByteArray.

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::read_uint_within_size

#![allow(unused)]
fn main() {
fn read_uint_within_size<
    T, +Add<T>, +Mul<T>, +Zero<T>, +TryInto<felt252, T>, +Drop<T>, +Into<u8, T>,
>(
    self: @ByteArray, offset: usize, size: usize,
) -> (usize, T)
}

append_u8

Append a u8 to ByteArray

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::append_u8

#![allow(unused)]
fn main() {
fn append_u8(ref self: ByteArray, value: u8)
}

append_u16

Append a u16 to ByteArray

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::append_u16

#![allow(unused)]
fn main() {
fn append_u16(ref self: ByteArray, value: u16)
}

append_u32

Append a u32 to ByteArray

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::append_u32

#![allow(unused)]
fn main() {
fn append_u32(ref self: ByteArray, value: u32)
}

append_usize

Append a usize to ByteArray

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::append_usize

#![allow(unused)]
fn main() {
fn append_usize(ref self: ByteArray, value: usize)
}

append_u64

Append a u64 to ByteArray

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::append_u64

#![allow(unused)]
fn main() {
fn append_u64(ref self: ByteArray, value: u64)
}

append_u128

Append a u128 to ByteArray

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::append_u128

#![allow(unused)]
fn main() {
fn append_u128(ref self: ByteArray, value: u128)
}

append_u256

Append a u256 to ByteArray

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::append_u256

#![allow(unused)]
fn main() {
fn append_u256(ref self: ByteArray, value: u256)
}

append_u512

Append a u512 to ByteArray

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::append_u512

#![allow(unused)]
fn main() {
fn append_u512(ref self: ByteArray, value: u512)
}

append_felt252

Append a felt252 to ByteArray

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::append_felt252

#![allow(unused)]
fn main() {
fn append_felt252(ref self: ByteArray, value: felt252)
}

append_address

Append a ContractAddress to ByteArray

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::append_address

#![allow(unused)]
fn main() {
fn append_address(ref self: ByteArray, value: ContractAddress)
}

append_bytes31

Append a bytes31 to ByteArray

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::append_bytes31

#![allow(unused)]
fn main() {
fn append_bytes31(ref self: ByteArray, value: bytes31)
}

update_at

Update a byte at a specific offset in ByteArray

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayTraitExtImpl::update_at

#![allow(unused)]
fn main() {
fn update_at(ref self: ByteArray, offset: usize, value: u8)
}

ByteArrayAppenderImpl

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayAppenderImpl

#![allow(unused)]
fn main() {
pub impl ByteArrayAppenderImpl of ByteAppender<T: ByteArray>
}

Impl functions

append_u16

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayAppenderImpl::append_u16

#![allow(unused)]
fn main() {
fn append_u16(ref self: ByteArray, word: u16)
}

append_u16_le

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayAppenderImpl::append_u16_le

#![allow(unused)]
fn main() {
fn append_u16_le(ref self: ByteArray, word: u16)
}

append_u32

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayAppenderImpl::append_u32

#![allow(unused)]
fn main() {
fn append_u32(ref self: ByteArray, word: u32)
}

append_u32_le

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayAppenderImpl::append_u32_le

#![allow(unused)]
fn main() {
fn append_u32_le(ref self: ByteArray, word: u32)
}

append_u64

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayAppenderImpl::append_u64

#![allow(unused)]
fn main() {
fn append_u64(ref self: ByteArray, word: u64)
}

append_u64_le

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayAppenderImpl::append_u64_le

#![allow(unused)]
fn main() {
fn append_u64_le(ref self: ByteArray, word: u64)
}

append_u128

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayAppenderImpl::append_u128

#![allow(unused)]
fn main() {
fn append_u128(ref self: ByteArray, word: u128)
}

append_u128_le

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayAppenderImpl::append_u128_le

#![allow(unused)]
fn main() {
fn append_u128_le(ref self: ByteArray, word: u128)
}

append_u256

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayAppenderImpl::append_u256

#![allow(unused)]
fn main() {
fn append_u256(ref self: ByteArray, word: u256)
}

append_u256_le

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayAppenderImpl::append_u256_le

#![allow(unused)]
fn main() {
fn append_u256_le(ref self: ByteArray, word: u256)
}

append_u512

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayAppenderImpl::append_u512

#![allow(unused)]
fn main() {
fn append_u512(ref self: ByteArray, word: u512)
}

append_u512_le

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayAppenderImpl::append_u512_le

#![allow(unused)]
fn main() {
fn append_u512_le(ref self: ByteArray, word: u512)
}

append_i8

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayAppenderImpl::append_i8

#![allow(unused)]
fn main() {
fn append_i8(ref self: ByteArray, word: i8)
}

append_i16

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayAppenderImpl::append_i16

#![allow(unused)]
fn main() {
fn append_i16(ref self: ByteArray, word: i16)
}

append_i16_le

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayAppenderImpl::append_i16_le

#![allow(unused)]
fn main() {
fn append_i16_le(ref self: ByteArray, word: i16)
}

append_i32

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayAppenderImpl::append_i32

#![allow(unused)]
fn main() {
fn append_i32(ref self: ByteArray, word: i32)
}

append_i32_le

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayAppenderImpl::append_i32_le

#![allow(unused)]
fn main() {
fn append_i32_le(ref self: ByteArray, word: i32)
}

append_i64

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayAppenderImpl::append_i64

#![allow(unused)]
fn main() {
fn append_i64(ref self: ByteArray, word: i64)
}

append_i64_le

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayAppenderImpl::append_i64_le

#![allow(unused)]
fn main() {
fn append_i64_le(ref self: ByteArray, word: i64)
}

append_i128

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayAppenderImpl::append_i128

#![allow(unused)]
fn main() {
fn append_i128(ref self: ByteArray, word: i128)
}

append_i128_le

Fully qualified path: alexandria_bytes::byte_array_ext::ByteArrayAppenderImpl::append_i128_le

#![allow(unused)]
fn main() {
fn append_i128_le(ref self: ByteArray, word: i128)
}

ByteArrayIntoBytes

Fully qualified path: alexandria_bytes::bytes::ByteArrayIntoBytes

#![allow(unused)]
fn main() {
pub impl ByteArrayIntoBytes of Into<ByteArray, Bytes>
}

Impl functions

into

Fully qualified path: alexandria_bytes::bytes::ByteArrayIntoBytes::into

#![allow(unused)]
fn main() {
fn into(self: ByteArray) -> Bytes
}

BytesIntoByteArray

Fully qualified path: alexandria_bytes::bytes::BytesIntoByteArray

#![allow(unused)]
fn main() {
pub impl BytesIntoByteArray of Into<Bytes, ByteArray>
}

Impl functions

into

Fully qualified path: alexandria_bytes::bytes::BytesIntoByteArray::into

#![allow(unused)]
fn main() {
fn into(self: Bytes) -> ByteArray
}

BytesDebug

Fully qualified path: alexandria_bytes::utils::BytesDebug

#![allow(unused)]
fn main() {
pub impl BytesDebug of Debug<Bytes>
}

Impl functions

fmt

Fully qualified path: alexandria_bytes::utils::BytesDebug::fmt

#![allow(unused)]
fn main() {
fn fmt(self: @Bytes, ref f: Formatter) -> Result<(), Error>
}

BytesDisplay

Fully qualified path: alexandria_bytes::utils::BytesDisplay

#![allow(unused)]
fn main() {
pub impl BytesDisplay of Display<Bytes>
}

Impl functions

fmt

Fully qualified path: alexandria_bytes::utils::BytesDisplay::fmt

#![allow(unused)]
fn main() {
fn fmt(self: @Bytes, ref f: Formatter) -> Result<(), Error>
}

Alexandria Bytes

Fully qualified path: alexandria_encoding

Modules

alexandria_encoding

Fully qualified path: alexandria_encoding

Modules

base58

Fully qualified path: alexandria_encoding::base58

Free functions

Traits

Impls

base64

Fully qualified path: alexandria_encoding::base64

Free functions

Traits

Impls

rlp

Fully qualified path: alexandria_encoding::rlp

Enums

Traits

Impls

rlp_byte_array

Fully qualified path: alexandria_encoding::rlp_byte_array

Enums

Traits

Impls

sol_abi

Fully qualified path: alexandria_encoding::sol_abi

Modules

decode

Fully qualified path: alexandria_encoding::sol_abi::decode

Traits

Impls

encode

Fully qualified path: alexandria_encoding::sol_abi::encode

Traits

Impls

encode_as

Fully qualified path: alexandria_encoding::sol_abi::encode_as

Traits

Impls

sol_bytes

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes

Traits

Free functions

encode_u8_array

Fully qualified path: alexandria_encoding::base58::encode_u8_array

#![allow(unused)]
fn main() {
pub fn encode_u8_array(bytes: Span<u8>, base58_chars: Span<u8>) -> Array<u8>
}

encode_u8_array

Encodes an array of u8 bytes into Base64 format. This function takes an array of bytes and converts them to Base64 encoding using the provided character set. It processes the input in groups of 3 bytes, converting them to 4 Base64 characters, and handles padding when necessary.

Arguments

  • bytes - A mutable array of u8 bytes to be encoded
  • base64_chars - A span containing the Base64 character set for encoding

Returns

  • Array<u8> - The Base64 encoded result as an array of bytes

Algorithm

  1. Groups input bytes into chunks of 3
  2. Converts each 3-byte chunk into a 24-bit number
  3. Splits the 24-bit number into four 6-bit values
  4. Maps each 6-bit value to a Base64 character
  5. Adds padding ('=') characters when input length is not divisible by 3

Fully qualified path: alexandria_encoding::base64::encode_u8_array

#![allow(unused)]
fn main() {
pub fn encode_u8_array(mut bytes: Array<u8>, base64_chars: Span<u8>) -> Array<u8>
}

encode_felt

Encodes a felt252 value into Base64 formatThis function converts a felt252 value to its Base64 representation using a specialized algorithm that handles the large numeric range of felt252. The encoding process divides the felt252 into manageable chunks and maps them to Base64 characters, with padding to ensure consistent output length.

Arguments

  • self - The felt252 value to be encoded
  • base64_chars - A span containing the Base64 character set for encoding

Returns

  • Array<u8> - The Base64 encoded result as an array of bytes, always 44 characters long # Algorithm 1. Converts felt252 to u256 for processing 2. Processes the number in chunks using division and modulo operations 3. Maps the resulting values to Base64 characters 4. Pads with 'A' characters to reach the standard 43-character length 5. Reverses the result and appends '=' padding character

Fully qualified path: alexandria_encoding::base64::encode_felt

#![allow(unused)]
fn main() {
pub fn encode_felt(self: felt252, base64_chars: Span<u8>) -> Array<u8>
}

encode_byte_array

Encodes a ByteArray into a Base64 encoded ByteArray.This function processes the input binary data in chunks of 3 bytes, converts them into their corresponding 6-bit values, and combines them into 24-bit numbers. It then maps these values to Base64 characters and handles any necessary padding.

Arguments

  • self - A mutable ByteArray containing the binary data to be encoded.
  • base64_chars - A Span containing the Base64 character set used for encoding.

Returns

  • A ByteArray containing the Base64 encoded data.

Fully qualified path: alexandria_encoding::base64::encode_byte_array

#![allow(unused)]
fn main() {
pub fn encode_byte_array(mut self: ByteArray, base64_chars: Span<u8>) -> ByteArray
}

Enums

RLPError

Fully qualified path: alexandria_encoding::rlp::RLPError

#![allow(unused)]
fn main() {
#[derive(Drop, Copy, PartialEq)]
pub enum RLPError {
    EmptyInput,
    InputTooShort,
    PayloadTooLong,
}
}

Variants

EmptyInput

Fully qualified path: alexandria_encoding::rlp::RLPError::EmptyInput

#![allow(unused)]
fn main() {
EmptyInput
}

InputTooShort

Fully qualified path: alexandria_encoding::rlp::RLPError::InputTooShort

#![allow(unused)]
fn main() {
InputTooShort
}

PayloadTooLong

Fully qualified path: alexandria_encoding::rlp::RLPError::PayloadTooLong

#![allow(unused)]
fn main() {
PayloadTooLong
}

RLPType

Fully qualified path: alexandria_encoding::rlp::RLPType

#![allow(unused)]
fn main() {
#[derive(Drop, PartialEq)]
pub enum RLPType {
    String,
    List,
}
}

Variants

String

Fully qualified path: alexandria_encoding::rlp::RLPType::String

#![allow(unused)]
fn main() {
String
}

List

Fully qualified path: alexandria_encoding::rlp::RLPType::List

#![allow(unused)]
fn main() {
List
}

RLPItem

Fully qualified path: alexandria_encoding::rlp::RLPItem

#![allow(unused)]
fn main() {
#[derive(Drop, Copy, PartialEq)]
pub enum RLPItem {
    String: Span<u8>,
    List: Span<RLPItem>,
}
}

Variants

String

Fully qualified path: alexandria_encoding::rlp::RLPItem::String

#![allow(unused)]
fn main() {
String : Span < u8 >
}

List

Fully qualified path: alexandria_encoding::rlp::RLPItem::List

#![allow(unused)]
fn main() {
List : Span < RLPItem >
}

RLPError

Fully qualified path: alexandria_encoding::rlp_byte_array::RLPError

#![allow(unused)]
fn main() {
#[derive(Drop, Copy, PartialEq)]
pub enum RLPError {
    EmptyInput,
    InputTooShort,
    PayloadTooLong,
}
}

Variants

EmptyInput

Fully qualified path: alexandria_encoding::rlp_byte_array::RLPError::EmptyInput

#![allow(unused)]
fn main() {
EmptyInput
}

InputTooShort

Fully qualified path: alexandria_encoding::rlp_byte_array::RLPError::InputTooShort

#![allow(unused)]
fn main() {
InputTooShort
}

PayloadTooLong

Fully qualified path: alexandria_encoding::rlp_byte_array::RLPError::PayloadTooLong

#![allow(unused)]
fn main() {
PayloadTooLong
}

RLPType

Fully qualified path: alexandria_encoding::rlp_byte_array::RLPType

#![allow(unused)]
fn main() {
#[derive(Drop, PartialEq)]
pub enum RLPType {
    String,
    List,
}
}

Variants

String

Fully qualified path: alexandria_encoding::rlp_byte_array::RLPType::String

#![allow(unused)]
fn main() {
String
}

List

Fully qualified path: alexandria_encoding::rlp_byte_array::RLPType::List

#![allow(unused)]
fn main() {
List
}

RLPItemByteArray

Fully qualified path: alexandria_encoding::rlp_byte_array::RLPItemByteArray

#![allow(unused)]
fn main() {
#[derive(Drop, PartialEq)]
pub enum RLPItemByteArray {
    String: ByteArray,
    List: Span<RLPItemByteArray>,
}
}

Variants

String

Fully qualified path: alexandria_encoding::rlp_byte_array::RLPItemByteArray::String

#![allow(unused)]
fn main() {
String : ByteArray
}

List

Fully qualified path: alexandria_encoding::rlp_byte_array::RLPItemByteArray::List

#![allow(unused)]
fn main() {
List : Span < RLPItemByteArray >
}

Traits

Encoder

Fully qualified path: alexandria_encoding::base58::Encoder

#![allow(unused)]
fn main() {
pub trait Encoder<T>
}

Trait functions

encode

Encodes data into Base58 format

Arguments

  • data - The data to encode

Returns

  • Array<u8> - Base58 encoded representation as bytes

Fully qualified path: alexandria_encoding::base58::Encoder::encode

#![allow(unused)]
fn main() {
fn encode(data: T) -> Array<u8>
}

Decoder

Fully qualified path: alexandria_encoding::base58::Decoder

#![allow(unused)]
fn main() {
pub trait Decoder<T>
}

Trait functions

decode

Decodes Base58 encoded data back to raw bytes

Arguments

  • data - The Base58 encoded data to decode

Returns

  • Array<u8> - Raw bytes decoded from Base58 format

Fully qualified path: alexandria_encoding::base58::Decoder::decode

#![allow(unused)]
fn main() {
fn decode(data: T) -> Array<u8>
}

Encoder

Generic trait for encoding data into Base64 formatThis trait provides a common interface for encoding various data types into Base64 representation, which is widely used for encoding binary data in text-based formats and data transmission. # Type Parameters * T - The input data type to be encoded

Fully qualified path: alexandria_encoding::base64::Encoder

#![allow(unused)]
fn main() {
pub trait Encoder<T>
}

Trait functions

encode

Encodes data into Base64 format

Arguments

  • data - The data to encode

Returns

  • Array<u8> - Base64 encoded representation as bytes

Fully qualified path: alexandria_encoding::base64::Encoder::encode

#![allow(unused)]
fn main() {
fn encode(data: T) -> Array<u8>
}

Decoder

Generic trait for decoding data from Base64 formatThis trait provides a common interface for decoding Base64 encoded data back to its original binary representation. # Type Parameters * T - The input data type to be decoded (typically Base64 encoded bytes)

Fully qualified path: alexandria_encoding::base64::Decoder

#![allow(unused)]
fn main() {
pub trait Decoder<T>
}

Trait functions

decode

Decodes Base64 encoded data back to raw bytes

Arguments

  • data - The Base64 encoded data to decode

Returns

  • Array<u8> - Raw bytes decoded from Base64 format

Fully qualified path: alexandria_encoding::base64::Decoder::decode

#![allow(unused)]
fn main() {
fn decode(data: T) -> Array<u8>
}

ByteArrayEncoder

Trait for encoding ByteArray data into Base64 formatThis trait is specialized for ByteArray types, providing efficient encoding operations while maintaining the ByteArray type for both input and output.

Fully qualified path: alexandria_encoding::base64::ByteArrayEncoder

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

Trait functions

encode

Encodes a ByteArray into Base64 format

Arguments

  • data - The ByteArray to encode

Returns

  • ByteArray - Base64 encoded representation as ByteArray

Fully qualified path: alexandria_encoding::base64::ByteArrayEncoder::encode

#![allow(unused)]
fn main() {
fn encode(data: ByteArray) -> ByteArray
}

ByteArrayDecoder

Trait for decoding ByteArray data from Base64 formatThis trait is specialized for ByteArray types, providing efficient decoding operations while maintaining the ByteArray type for both input and output.

Fully qualified path: alexandria_encoding::base64::ByteArrayDecoder

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

Trait functions

decode

Decodes a Base64 encoded ByteArray back to raw bytes

Arguments

  • data - The Base64 encoded ByteArray to decode

Returns

  • ByteArray - Raw bytes decoded from Base64 format as ByteArray

Fully qualified path: alexandria_encoding::base64::ByteArrayDecoder::decode

#![allow(unused)]
fn main() {
fn decode(data: ByteArray) -> ByteArray
}

RLPTrait

Fully qualified path: alexandria_encoding::rlp::RLPTrait

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

Trait functions

decode_type

Returns RLPType from the leading byte with its offset in the array as well as its size.

Arguments

  • input - Array of byte to decode

Returns

  • (RLPType, offset, size) - A tuple containing the RLPType the offset and the size of the RLPItem to decode # Errors _ empty input - if the input is empty _ input too short - if the input is too short for a given

Fully qualified path: alexandria_encoding::rlp::RLPTrait::decode_type

#![allow(unused)]
fn main() {
fn decode_type(input: Span<u8>) -> Result<(RLPType, u32, u32), RLPError>
}

encode

Recursively encodes multiple a list of RLPItems

Arguments

  • input - Span of RLPItem to encode

Returns

  • `Span - RLP encoded items as a span of bytes # Errors * empty input - if the input is empty

Fully qualified path: alexandria_encoding::rlp::RLPTrait::encode

#![allow(unused)]
fn main() {
fn encode(input: Span<RLPItem>) -> Result<Span<u8>, RLPError>
}

encode_string

RLP encodes a Array of bytes representing a RLP String.

Arguments

  • input - Array of bytes representing a RLP String to encode

Returns

  • `Span - RLP encoded items as a span of bytes

Fully qualified path: alexandria_encoding::rlp::RLPTrait::encode_string

#![allow(unused)]
fn main() {
fn encode_string(input: Span<u8>) -> Result<Span<u8>, RLPError>
}

decode

Recursively decodes a rlp encoded byte array as described in https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp/

Arguments

  • input - Array of bytes to decode

Returns

  • Span<RLPItem> - Span of RLPItem # Errors * input too short - if the input is too short for a given

Fully qualified path: alexandria_encoding::rlp::RLPTrait::decode

#![allow(unused)]
fn main() {
fn decode(input: Span<u8>) -> Result<Span<RLPItem>, RLPError>
}

RLPTrait

Fully qualified path: alexandria_encoding::rlp_byte_array::RLPTrait

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

Trait functions

encode_byte_array

Encodes a Span of RLPItemByteArray (which can be either strings or lists) into a single RLP-encoded ByteArray. This function handles recursive encoding for nested lists.

Parameters

  • input: A Span containing RLP items, where each item is either a string (ByteArray) or a nested list (Span).
  • prefix: can be used for ex eip1559 is 0x2

Returns

  • Result<@ByteArray, RLPError>: The RLP-encoded result or an error if input is empty.

Fully qualified path: alexandria_encoding::rlp_byte_array::RLPTrait::encode_byte_array

#![allow(unused)]
fn main() {
fn encode_byte_array(input: Span<RLPItemByteArray>, prefix: u8) -> Result<@ByteArray, RLPError>
}

encode_byte_array_string

Encodes a ByteArray as an RLP string (not a list).

Parameters * input: A reference to the ByteArray to encode.

Returns

  • Result<@ByteArray, RLPError>: The RLP-encoded result or an error.

RLP Encoding Rules for Strings:

  • For empty string, the encoding is 0x80.
  • For single byte less than 0x80, it’s the byte itself (no prefix).
  • For strings with length < 56, prefix is 0x80 + length.
  • For strings with length >= 56, prefix is 0xb7 + length-of-length, followed by actual length and data.

Fully qualified path: alexandria_encoding::rlp_byte_array::RLPTrait::encode_byte_array_string

#![allow(unused)]
fn main() {
fn encode_byte_array_string(input: @ByteArray) -> Result<@ByteArray, RLPError>
}

encode_byte_array_list

Encodes a list of RLP-encoded ByteArrays into a single RLP list item. Assumes all input elements are already RLP-encoded. Used for creating composite structures like transaction lists or EIP-1559 typed payloads.

Arguments

  • inputs - Span of RLP-encoded @ByteArray items to be wrapped in a list.
  • prefix - Optional prefix byte (e.g., 0x2 for EIP-1559), 0 if unused.

Returns

  • @ByteArray - a new RLP-encoded ByteArray representing the list.

Behavior

  • Uses short or long list prefix depending on total payload size.
  • Adds prefix byte if prefix > 0.

Fully qualified path: alexandria_encoding::rlp_byte_array::RLPTrait::encode_byte_array_list

#![allow(unused)]
fn main() {
fn encode_byte_array_list(inputs: Span<@ByteArray>, prefix: u8) -> Result<@ByteArray, RLPError>
}

decode_byte_array

Recursively decodes a rlp encoded byte array as described in https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp/

Arguments

  • input - ByteArray decode

Returns

  • Span<ByteArray> - decoded ByteArray

Errors

  • input too short - if the input is too short for a given
  • empty input - if the input is len is 0

Fully qualified path: alexandria_encoding::rlp_byte_array::RLPTrait::decode_byte_array

#![allow(unused)]
fn main() {
fn decode_byte_array(input: @ByteArray) -> Result<Span<ByteArray>, RLPError>
}

decode_byte_array_type

Decodes the RLP prefix of the input and determines the type (String or List), returning the decoded payload, the total bytes read, and the inferred RLP type.

Parameters

  • input: Reference to a ByteArray that represents RLP-encoded data.

Returns

  • Ok((payload, total_bytes_read, RLPType)): On success, returns the decoded payload, how many bytes were consumed from input, and whether it was a String or List.

  • Err(RLPError): If decoding fails due to invalid input length, or size issues.

Fully qualified path: alexandria_encoding::rlp_byte_array::RLPTrait::decode_byte_array_type

#![allow(unused)]
fn main() {
fn decode_byte_array_type(input: @ByteArray) -> Result<(ByteArray, u32, RLPType), RLPError>
}

SolAbiDecodeTrait

Decode trait meant to provide an interface similar to Solidity's abi.decode function. It is meant to be used in a chain where the passed in offset is updated after each decode operation. Values are expected to be 32 bytes long, and will be interpreted as if they were encoded using the abi.encode function in Solidity.

Fully qualified path: alexandria_encoding::sol_abi::decode::SolAbiDecodeTrait

#![allow(unused)]
fn main() {
pub trait SolAbiDecodeTrait<T>
}

Trait functions

decode

Decodes a value of type T from bytes starting at the given offset

Arguments

  • self - Reference to the Bytes containing encoded data
  • offset - Mutable reference to the current offset position (updated after decode)

Returns

  • T - The decoded value of type T

Fully qualified path: alexandria_encoding::sol_abi::decode::SolAbiDecodeTrait::decode

#![allow(unused)]
fn main() {
fn decode(self: @Bytes, ref offset: usize) -> T
}

SolAbiEncodeSelectorTrait

Encode selector trait meant to provide an interface similar to Solidity's abi.encodeWithSelector function. It is meant to be the first call in an encode chain, adding the function selector to the encoded data. Value encoded is only 4 bytes long representing the function selector. Use like this: BytesTrait::new_empty().encode_selector(selector).encode(arg1).encode(arg2)...

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeSelectorTrait

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

Trait functions

encode_selector

Encodes a function selector as 4 bytes at the beginning of the data

Arguments

  • self - The Bytes object to append the selector to
  • selector - The 4-byte function selector (u32)

Returns

  • Bytes - The original Bytes object with the selector appended

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeSelectorTrait::encode_selector

#![allow(unused)]
fn main() {
fn encode_selector(self: Bytes, selector: u32) -> Bytes
}

SolAbiEncodeTrait

Encode trait meant to provide an interface similar to Solidity's abi.encode function. It is meant to allow chaining of encode calls to build up a Bytes object. Values are encoded in 32 bytes chunks, and padding is added as necessary. Also provides a packed version of the encoding similar to Solidity's abi.encodePacked, which does not add padding. Use like this: BytesTrait::new_empty().encode(arg1).encode(arg2)... Or like this: BytesTrait::new_empty().encode_packed(arg1).encode_packed(arg2)...

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeTrait

#![allow(unused)]
fn main() {
pub trait SolAbiEncodeTrait<T>
}

Trait functions

encode

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeTrait::encode

#![allow(unused)]
fn main() {
fn encode(self: Bytes, x: T) -> Bytes
}

encode_packed

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeTrait::encode_packed

#![allow(unused)]
fn main() {
fn encode_packed(self: Bytes, x: T) -> Bytes
}

SolAbiEncodeAsTrait

Encode trait for arbitrarily sized encodings, meant to allow easy bytesX type encodings. Encode the value x as Bytes with a specific byteSize. Allows chaining of encode/encode_as calls to build up a Bytes object. Use like : let encoded: Bytes = Bytes::new_empty().encode_as(32, x).encode_as(13, y)...

Fully qualified path: alexandria_encoding::sol_abi::encode_as::SolAbiEncodeAsTrait

#![allow(unused)]
fn main() {
pub trait SolAbiEncodeAsTrait<T>
}

Trait functions

encode_as

Encodes a value of type T into bytes with specified byte size

Arguments

  • self - The Bytes object to append encoded data to
  • byteSize - The number of bytes to use for encoding (must be <= 32)
  • x - The value to encode

Returns

  • Bytes - The original Bytes object with the encoded value appended

Fully qualified path: alexandria_encoding::sol_abi::encode_as::SolAbiEncodeAsTrait::encode_as

#![allow(unused)]
fn main() {
fn encode_as(self: Bytes, byteSize: usize, x: T) -> Bytes
}

SolBytesTrait

Solidity Bytes Trait meant to provide an interface similar to Solidity's bytesX types, like bytes1, bytes2, bytes3, ..., bytes32. Acts as a wrapper around the encode_as to make it easier to understand and use. Use like this: let bytes7Val: Bytes = SolBytesTrait::bytes7(0x01020304050607_u128);

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait

#![allow(unused)]
fn main() {
pub trait SolBytesTrait<T>
}

Trait functions

bytes1

Creates 1-byte representation of a value

Arguments

  • val - The value to encode as 1 byte

Returns

  • Bytes - 1-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes1

#![allow(unused)]
fn main() {
fn bytes1(val: T) -> Bytes
}

bytes2

Creates 2-byte representation of a value

Arguments

  • val - The value to encode as 2 bytes

Returns

  • Bytes - 2-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes2

#![allow(unused)]
fn main() {
fn bytes2(val: T) -> Bytes
}

bytes3

Creates 3-byte representation of a value

Arguments

  • val - The value to encode as 3 bytes

Returns

  • Bytes - 3-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes3

#![allow(unused)]
fn main() {
fn bytes3(val: T) -> Bytes
}

bytes4

Creates 4-byte representation of a value

Arguments

  • val - The value to encode as 4 bytes

Returns

  • Bytes - 4-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes4

#![allow(unused)]
fn main() {
fn bytes4(val: T) -> Bytes
}

bytes5

Creates 5-byte representation of a value

Arguments

  • val - The value to encode as 5 bytes

Returns

  • Bytes - 5-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes5

#![allow(unused)]
fn main() {
fn bytes5(val: T) -> Bytes
}

bytes6

Creates 6-byte representation of a value

Arguments

  • val - The value to encode as 6 bytes

Returns

  • Bytes - 6-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes6

#![allow(unused)]
fn main() {
fn bytes6(val: T) -> Bytes
}

bytes7

Creates 7-byte representation of a value

Arguments

  • val - The value to encode as 7 bytes

Returns

  • Bytes - 7-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes7

#![allow(unused)]
fn main() {
fn bytes7(val: T) -> Bytes
}

bytes8

Creates 8-byte representation of a value

Arguments

  • val - The value to encode as 8 bytes

Returns

  • Bytes - 8-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes8

#![allow(unused)]
fn main() {
fn bytes8(val: T) -> Bytes
}

bytes9

Creates 9-byte representation of a value

Arguments

  • val - The value to encode as 9 bytes

Returns

  • Bytes - 9-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes9

#![allow(unused)]
fn main() {
fn bytes9(val: T) -> Bytes
}

bytes10

Creates 10-byte representation of a value

Arguments

  • val - The value to encode as 10 bytes

Returns

  • Bytes - 10-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes10

#![allow(unused)]
fn main() {
fn bytes10(val: T) -> Bytes
}

bytes11

Creates 11-byte representation of a value

Arguments

  • val - The value to encode as 11 bytes

Returns

  • Bytes - 11-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes11

#![allow(unused)]
fn main() {
fn bytes11(val: T) -> Bytes
}

bytes12

Creates 12-byte representation of a value

Arguments

  • val - The value to encode as 12 bytes

Returns

  • Bytes - 12-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes12

#![allow(unused)]
fn main() {
fn bytes12(val: T) -> Bytes
}

bytes13

Creates 13-byte representation of a value

Arguments

  • val - The value to encode as 13 bytes

Returns

  • Bytes - 13-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes13

#![allow(unused)]
fn main() {
fn bytes13(val: T) -> Bytes
}

bytes14

Creates 14-byte representation of a value

Arguments

  • val - The value to encode as 14 bytes

Returns

  • Bytes - 14-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes14

#![allow(unused)]
fn main() {
fn bytes14(val: T) -> Bytes
}

bytes15

Creates 15-byte representation of a value

Arguments

  • val - The value to encode as 15 bytes

Returns

  • Bytes - 15-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes15

#![allow(unused)]
fn main() {
fn bytes15(val: T) -> Bytes
}

bytes16

Creates 16-byte representation of a value

Arguments

  • val - The value to encode as 16 bytes

Returns

  • Bytes - 16-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes16

#![allow(unused)]
fn main() {
fn bytes16(val: T) -> Bytes
}

bytes17

Creates 17-byte representation of a value

Arguments

  • val - The value to encode as 17 bytes

Returns

  • Bytes - 17-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes17

#![allow(unused)]
fn main() {
fn bytes17(val: T) -> Bytes
}

bytes18

Creates 18-byte representation of a value

Arguments

  • val - The value to encode as 18 bytes

Returns

  • Bytes - 18-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes18

#![allow(unused)]
fn main() {
fn bytes18(val: T) -> Bytes
}

bytes19

Creates 19-byte representation of a value

Arguments

  • val - The value to encode as 19 bytes

Returns

  • Bytes - 19-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes19

#![allow(unused)]
fn main() {
fn bytes19(val: T) -> Bytes
}

bytes20

Creates 20-byte representation of a value

Arguments

  • val - The value to encode as 20 bytes

Returns

  • Bytes - 20-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes20

#![allow(unused)]
fn main() {
fn bytes20(val: T) -> Bytes
}

bytes21

Creates 21-byte representation of a value

Arguments

  • val - The value to encode as 21 bytes

Returns

  • Bytes - 21-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes21

#![allow(unused)]
fn main() {
fn bytes21(val: T) -> Bytes
}

bytes22

Creates 22-byte representation of a value

Arguments

  • val - The value to encode as 22 bytes

Returns

  • Bytes - 22-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes22

#![allow(unused)]
fn main() {
fn bytes22(val: T) -> Bytes
}

bytes23

Creates 23-byte representation of a value

Arguments

  • val - The value to encode as 23 bytes

Returns

  • Bytes - 23-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes23

#![allow(unused)]
fn main() {
fn bytes23(val: T) -> Bytes
}

bytes24

Creates 24-byte representation of a value

Arguments

  • val - The value to encode as 24 bytes

Returns

  • Bytes - 24-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes24

#![allow(unused)]
fn main() {
fn bytes24(val: T) -> Bytes
}

bytes25

Creates 25-byte representation of a value

Arguments

  • val - The value to encode as 25 bytes

Returns

  • Bytes - 25-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes25

#![allow(unused)]
fn main() {
fn bytes25(val: T) -> Bytes
}

bytes26

Creates 26-byte representation of a value

Arguments

  • val - The value to encode as 26 bytes

Returns

  • Bytes - 26-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes26

#![allow(unused)]
fn main() {
fn bytes26(val: T) -> Bytes
}

bytes27

Creates 27-byte representation of a value

Arguments

  • val - The value to encode as 27 bytes

Returns

  • Bytes - 27-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes27

#![allow(unused)]
fn main() {
fn bytes27(val: T) -> Bytes
}

bytes28

Creates 28-byte representation of a value

Arguments

  • val - The value to encode as 28 bytes

Returns

  • Bytes - 28-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes28

#![allow(unused)]
fn main() {
fn bytes28(val: T) -> Bytes
}

bytes29

Creates 29-byte representation of a value

Arguments

  • val - The value to encode as 29 bytes

Returns

  • Bytes - 29-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes29

#![allow(unused)]
fn main() {
fn bytes29(val: T) -> Bytes
}

bytes30

Creates 30-byte representation of a value

Arguments

  • val - The value to encode as 30 bytes

Returns

  • Bytes - 30-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes30

#![allow(unused)]
fn main() {
fn bytes30(val: T) -> Bytes
}

bytes31

Creates 31-byte representation of a value

Arguments

  • val - The value to encode as 31 bytes

Returns

  • Bytes - 31-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes31

#![allow(unused)]
fn main() {
fn bytes31(val: T) -> Bytes
}

bytes32

Creates 32-byte representation of a value

Arguments

  • val - The value to encode as 32 bytes

Returns

  • Bytes - 32-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes32

#![allow(unused)]
fn main() {
fn bytes32(val: T) -> Bytes
}

bytes

Creates n-byte representation of a value

Arguments

  • len - The number of bytes to use for encoding
  • val - The value to encode

Returns

  • Bytes - n-byte encoded representation

Fully qualified path: alexandria_encoding::sol_abi::sol_bytes::SolBytesTrait::bytes

#![allow(unused)]
fn main() {
fn bytes(len: usize, val: T) -> Bytes
}

Impls

Base58Encoder

Base58 encoder implementation for u8 spans

Fully qualified path: alexandria_encoding::base58::Base58Encoder

#![allow(unused)]
fn main() {
pub impl Base58Encoder of Encoder<Span<u8>>
}

Impl functions

encode

Fully qualified path: alexandria_encoding::base58::Base58Encoder::encode

#![allow(unused)]
fn main() {
fn encode(data: Span<u8>) -> Array<u8>
}

Base58Decoder

Fully qualified path: alexandria_encoding::base58::Base58Decoder

#![allow(unused)]
fn main() {
pub impl Base58Decoder of Decoder<Span<u8>>
}

Impl functions

decode

Fully qualified path: alexandria_encoding::base58::Base58Decoder::decode

#![allow(unused)]
fn main() {
fn decode(data: Span<u8>) -> Array<u8>
}

Base64Encoder

Fully qualified path: alexandria_encoding::base64::Base64Encoder

#![allow(unused)]
fn main() {
pub impl Base64Encoder of Encoder<Array<u8>>
}

Impl functions

encode

Fully qualified path: alexandria_encoding::base64::Base64Encoder::encode

#![allow(unused)]
fn main() {
fn encode(data: Array<u8>) -> Array<u8>
}

Base64UrlEncoder

Fully qualified path: alexandria_encoding::base64::Base64UrlEncoder

#![allow(unused)]
fn main() {
pub impl Base64UrlEncoder of Encoder<Array<u8>>
}

Impl functions

encode

Fully qualified path: alexandria_encoding::base64::Base64UrlEncoder::encode

#![allow(unused)]
fn main() {
fn encode(data: Array<u8>) -> Array<u8>
}

Base64FeltEncoder

Fully qualified path: alexandria_encoding::base64::Base64FeltEncoder

#![allow(unused)]
fn main() {
pub impl Base64FeltEncoder of Encoder<felt252>
}

Impl functions

encode

Fully qualified path: alexandria_encoding::base64::Base64FeltEncoder::encode

#![allow(unused)]
fn main() {
fn encode(data: felt252) -> Array<u8>
}

Base64UrlFeltEncoder

Fully qualified path: alexandria_encoding::base64::Base64UrlFeltEncoder

#![allow(unused)]
fn main() {
pub impl Base64UrlFeltEncoder of Encoder<felt252>
}

Impl functions

encode

Fully qualified path: alexandria_encoding::base64::Base64UrlFeltEncoder::encode

#![allow(unused)]
fn main() {
fn encode(data: felt252) -> Array<u8>
}

Base64ByteArrayEncoder

Fully qualified path: alexandria_encoding::base64::Base64ByteArrayEncoder

#![allow(unused)]
fn main() {
pub impl Base64ByteArrayEncoder of ByteArrayEncoder
}

Impl functions

encode

Fully qualified path: alexandria_encoding::base64::Base64ByteArrayEncoder::encode

#![allow(unused)]
fn main() {
fn encode(data: ByteArray) -> ByteArray
}

Base64ByteArrayUrlEncoder

Fully qualified path: alexandria_encoding::base64::Base64ByteArrayUrlEncoder

#![allow(unused)]
fn main() {
pub impl Base64ByteArrayUrlEncoder of ByteArrayEncoder
}

Impl functions

encode

Fully qualified path: alexandria_encoding::base64::Base64ByteArrayUrlEncoder::encode

#![allow(unused)]
fn main() {
fn encode(data: ByteArray) -> ByteArray
}

Base64Decoder

Fully qualified path: alexandria_encoding::base64::Base64Decoder

#![allow(unused)]
fn main() {
pub impl Base64Decoder of Decoder<Array<u8>>
}

Impl functions

decode

Fully qualified path: alexandria_encoding::base64::Base64Decoder::decode

#![allow(unused)]
fn main() {
fn decode(data: Array<u8>) -> Array<u8>
}

Base64UrlDecoder

Fully qualified path: alexandria_encoding::base64::Base64UrlDecoder

#![allow(unused)]
fn main() {
pub impl Base64UrlDecoder of Decoder<Array<u8>>
}

Impl functions

decode

Fully qualified path: alexandria_encoding::base64::Base64UrlDecoder::decode

#![allow(unused)]
fn main() {
fn decode(data: Array<u8>) -> Array<u8>
}

Base64ByteArrayDecoder

Fully qualified path: alexandria_encoding::base64::Base64ByteArrayDecoder

#![allow(unused)]
fn main() {
pub impl Base64ByteArrayDecoder of ByteArrayDecoder
}

Impl functions

decode

Fully qualified path: alexandria_encoding::base64::Base64ByteArrayDecoder::decode

#![allow(unused)]
fn main() {
fn decode(data: ByteArray) -> ByteArray
}

RLPImpl

Fully qualified path: alexandria_encoding::rlp::RLPImpl

#![allow(unused)]
fn main() {
pub impl RLPImpl of RLPTrait
}

Impl functions

decode_type

Returns RLPType from the leading byte with its offset in the array as well as its size.

Arguments

  • input - Array of byte to decode

Returns

  • (RLPType, offset, size) - A tuple containing the RLPType the offset and the size of the RLPItem to decode # Errors _ empty input - if the input is empty _ input too short - if the input is too short for a given

Fully qualified path: alexandria_encoding::rlp::RLPImpl::decode_type

#![allow(unused)]
fn main() {
fn decode_type(input: Span<u8>) -> Result<(RLPType, u32, u32), RLPError>
}

encode

Recursively encodes multiple a list of RLPItems

Arguments

  • input - Span of RLPItem to encode

Returns

  • `Span - RLP encoded items as a span of bytes # Errors * empty input - if the input is empty

Fully qualified path: alexandria_encoding::rlp::RLPImpl::encode

#![allow(unused)]
fn main() {
fn encode(mut input: Span<RLPItem>) -> Result<Span<u8>, RLPError>
}

encode_string

RLP encodes a Array of bytes representing a RLP String.

Arguments

  • input - Array of bytes representing a RLP String to encode

Returns

  • `Span - RLP encoded items as a span of bytes

Fully qualified path: alexandria_encoding::rlp::RLPImpl::encode_string

#![allow(unused)]
fn main() {
fn encode_string(input: Span<u8>) -> Result<Span<u8>, RLPError>
}

decode

Recursively decodes a rlp encoded byte array as described in https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp/

Arguments

  • input - Array of bytes to decode

Returns

  • Span<RLPItem> - Span of RLPItem # Errors * input too short - if the input is too short for a given

Fully qualified path: alexandria_encoding::rlp::RLPImpl::decode

#![allow(unused)]
fn main() {
fn decode(input: Span<u8>) -> Result<Span<RLPItem>, RLPError>
}

RLPImpl

Fully qualified path: alexandria_encoding::rlp_byte_array::RLPImpl

#![allow(unused)]
fn main() {
pub impl RLPImpl of RLPTrait
}

Impl functions

encode_byte_array

Encodes a Span of RLPItemByteArray (which can be either strings or lists) into a single RLP-encoded ByteArray. This function handles recursive encoding for nested lists. # Parameters _ input: A Span containing RLP items, where each item is either a string (ByteArray) or a nested list (Span). _ prefix: can be used for ex eip1559 is 0x2

Returns

  • Result<@ByteArray, RLPError>: The RLP-encoded result or an error if input is empty.

Fully qualified path: alexandria_encoding::rlp_byte_array::RLPImpl::encode_byte_array

#![allow(unused)]
fn main() {
fn encode_byte_array(mut input: Span<RLPItemByteArray>, prefix: u8) -> Result<@ByteArray, RLPError>
}

encode_byte_array_string

Encodes a ByteArray as an RLP string (not a list). # Parameters * input: A reference to the ByteArray to encode.

Returns

  • Result<@ByteArray, RLPError>: The RLP-encoded result or an error. ## RLP Encoding Rules for Strings: _ For empty string, the encoding is 0x80. _ For single byte less than 0x80, it’s the byte itself (no prefix). _ For strings with length < 56, prefix is 0x80 + length. _ For strings with length >= 56, prefix is 0xb7 + length-of-length, followed by actual length and data.

Fully qualified path: alexandria_encoding::rlp_byte_array::RLPImpl::encode_byte_array_string

#![allow(unused)]
fn main() {
fn encode_byte_array_string(input: @ByteArray) -> Result<@ByteArray, RLPError>
}

encode_byte_array_list

Encodes a list of RLP-encoded ByteArrays into a single RLP list item. Assumes all input elements are already RLP-encoded. Used for creating composite structures like transaction lists or EIP-1559 typed payloads.

Arguments

  • inputs - Span of RLP-encoded @ByteArray items to be wrapped in a list.
  • prefix - Optional prefix byte (e.g., 0x2 for EIP-1559), 0 if unused.

Returns

  • @ByteArray - a new RLP-encoded ByteArray representing the list.

Behavior

  • Uses short or long list prefix depending on total payload size.
  • Adds prefix byte if prefix > 0.

Fully qualified path: alexandria_encoding::rlp_byte_array::RLPImpl::encode_byte_array_list

#![allow(unused)]
fn main() {
fn encode_byte_array_list(mut inputs: Span<@ByteArray>, prefix: u8) -> Result<@ByteArray, RLPError>
}

decode_byte_array

Recursively decodes a rlp encoded byte array as described in https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp/

Arguments

  • input - ByteArray decode

Returns

  • Span<ByteArray> - decoded ByteArray # Errors _ input too short - if the input is too short for a given _ empty input - if the input is len is 0

Fully qualified path: alexandria_encoding::rlp_byte_array::RLPImpl::decode_byte_array

#![allow(unused)]
fn main() {
fn decode_byte_array(input: @ByteArray) -> Result<Span<ByteArray>, RLPError>
}

decode_byte_array_type

Decodes the RLP prefix of the input and determines the type (String or List), returning the decoded payload, the total bytes read, and the inferred RLP type. # Parameters * input: Reference to a ByteArray that represents RLP-encoded data.

Returns

  • Ok((payload, total_bytes_read, RLPType)): On success, returns the decoded payload, how many bytes were consumed from input, and whether it was a String or List. * Err(RLPError): If decoding fails due to invalid input length, or size issues.

Fully qualified path: alexandria_encoding::rlp_byte_array::RLPImpl::decode_byte_array_type

#![allow(unused)]
fn main() {
fn decode_byte_array_type(input: @ByteArray) -> Result<(ByteArray, u32, RLPType), RLPError>
}

SolAbiDecodeU8

Decode int types Integers are decoded by reading 32 bytes from the offset Bytes encoding is right-aligned/left-paddded Big-endian.

Fully qualified path: alexandria_encoding::sol_abi::decode::SolAbiDecodeU8

#![allow(unused)]
fn main() {
pub impl SolAbiDecodeU8 of SolAbiDecodeTrait<u8>
}

Impl functions

decode

Fully qualified path: alexandria_encoding::sol_abi::decode::SolAbiDecodeU8::decode

#![allow(unused)]
fn main() {
fn decode(self: @Bytes, ref offset: usize) -> u8
}

SolAbiDecodeU16

Fully qualified path: alexandria_encoding::sol_abi::decode::SolAbiDecodeU16

#![allow(unused)]
fn main() {
pub impl SolAbiDecodeU16 of SolAbiDecodeTrait<u16>
}

Impl functions

decode

Fully qualified path: alexandria_encoding::sol_abi::decode::SolAbiDecodeU16::decode

#![allow(unused)]
fn main() {
fn decode(self: @Bytes, ref offset: usize) -> u16
}

SolAbiDecodeU32

Fully qualified path: alexandria_encoding::sol_abi::decode::SolAbiDecodeU32

#![allow(unused)]
fn main() {
pub impl SolAbiDecodeU32 of SolAbiDecodeTrait<u32>
}

Impl functions

decode

Fully qualified path: alexandria_encoding::sol_abi::decode::SolAbiDecodeU32::decode

#![allow(unused)]
fn main() {
fn decode(self: @Bytes, ref offset: usize) -> u32
}

SolAbiDecodeU64

Fully qualified path: alexandria_encoding::sol_abi::decode::SolAbiDecodeU64

#![allow(unused)]
fn main() {
pub impl SolAbiDecodeU64 of SolAbiDecodeTrait<u64>
}

Impl functions

decode

Fully qualified path: alexandria_encoding::sol_abi::decode::SolAbiDecodeU64::decode

#![allow(unused)]
fn main() {
fn decode(self: @Bytes, ref offset: usize) -> u64
}

SolAbiDecodeU128

Fully qualified path: alexandria_encoding::sol_abi::decode::SolAbiDecodeU128

#![allow(unused)]
fn main() {
pub impl SolAbiDecodeU128 of SolAbiDecodeTrait<u128>
}

Impl functions

decode

Fully qualified path: alexandria_encoding::sol_abi::decode::SolAbiDecodeU128::decode

#![allow(unused)]
fn main() {
fn decode(self: @Bytes, ref offset: usize) -> u128
}

SolAbiDecodeU256

Fully qualified path: alexandria_encoding::sol_abi::decode::SolAbiDecodeU256

#![allow(unused)]
fn main() {
pub impl SolAbiDecodeU256 of SolAbiDecodeTrait<u256>
}

Impl functions

decode

Fully qualified path: alexandria_encoding::sol_abi::decode::SolAbiDecodeU256::decode

#![allow(unused)]
fn main() {
fn decode(self: @Bytes, ref offset: usize) -> u256
}

SolAbiDecodeBool

Decode other primitives Primitives are decoded by reading 32 bytes from the offset Bytes encoding is right-aligned/left-paddded Big-endian.

Fully qualified path: alexandria_encoding::sol_abi::decode::SolAbiDecodeBool

#![allow(unused)]
fn main() {
pub impl SolAbiDecodeBool of SolAbiDecodeTrait<bool>
}

Impl functions

decode

Fully qualified path: alexandria_encoding::sol_abi::decode::SolAbiDecodeBool::decode

#![allow(unused)]
fn main() {
fn decode(self: @Bytes, ref offset: usize) -> bool
}

SolAbiDecodeFelt252

Fully qualified path: alexandria_encoding::sol_abi::decode::SolAbiDecodeFelt252

#![allow(unused)]
fn main() {
pub impl SolAbiDecodeFelt252 of SolAbiDecodeTrait<felt252>
}

Impl functions

decode

Fully qualified path: alexandria_encoding::sol_abi::decode::SolAbiDecodeFelt252::decode

#![allow(unused)]
fn main() {
fn decode(self: @Bytes, ref offset: usize) -> felt252
}

SolAbiDecodeBytes31

Fully qualified path: alexandria_encoding::sol_abi::decode::SolAbiDecodeBytes31

#![allow(unused)]
fn main() {
pub impl SolAbiDecodeBytes31 of SolAbiDecodeTrait<bytes31>
}

Impl functions

decode

Fully qualified path: alexandria_encoding::sol_abi::decode::SolAbiDecodeBytes31::decode

#![allow(unused)]
fn main() {
fn decode(self: @Bytes, ref offset: usize) -> bytes31
}

SolAbiDecodeBytes

Decode byte types Bytes are decoded by reading 32 bytes from the offset Bytes encoding is left-aligned/right-paddded

Fully qualified path: alexandria_encoding::sol_abi::decode::SolAbiDecodeBytes

#![allow(unused)]
fn main() {
pub impl SolAbiDecodeBytes of SolAbiDecodeTrait<Bytes>
}

Impl functions

decode

Fully qualified path: alexandria_encoding::sol_abi::decode::SolAbiDecodeBytes::decode

#![allow(unused)]
fn main() {
fn decode(self: @Bytes, ref offset: usize) -> Bytes
}

SolAbiDecodeByteArray

Fully qualified path: alexandria_encoding::sol_abi::decode::SolAbiDecodeByteArray

#![allow(unused)]
fn main() {
pub impl SolAbiDecodeByteArray of SolAbiDecodeTrait<ByteArray>
}

Impl functions

decode

Fully qualified path: alexandria_encoding::sol_abi::decode::SolAbiDecodeByteArray::decode

#![allow(unused)]
fn main() {
fn decode(self: @Bytes, ref offset: usize) -> ByteArray
}

SolAbiDecodeStarknetAddress

Decode address types Addresses are decoded by reading 32 bytes from the offset Bytes encoding is right-aligned/left-paddded Big-endian.

Fully qualified path: alexandria_encoding::sol_abi::decode::SolAbiDecodeStarknetAddress

#![allow(unused)]
fn main() {
pub impl SolAbiDecodeStarknetAddress of SolAbiDecodeTrait<ContractAddress>
}

Impl functions

decode

Fully qualified path: alexandria_encoding::sol_abi::decode::SolAbiDecodeStarknetAddress::decode

#![allow(unused)]
fn main() {
fn decode(self: @Bytes, ref offset: usize) -> ContractAddress
}

SolAbiDecodeEthAddress

Fully qualified path: alexandria_encoding::sol_abi::decode::SolAbiDecodeEthAddress

#![allow(unused)]
fn main() {
pub impl SolAbiDecodeEthAddress of SolAbiDecodeTrait<EthAddress>
}

Impl functions

decode

Fully qualified path: alexandria_encoding::sol_abi::decode::SolAbiDecodeEthAddress::decode

#![allow(unused)]
fn main() {
fn decode(self: @Bytes, ref offset: usize) -> EthAddress
}

SolAbiEncodeSelector

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeSelector

#![allow(unused)]
fn main() {
pub impl SolAbiEncodeSelector of SolAbiEncodeSelectorTrait
}

Impl functions

encode_selector

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeSelector::encode_selector

#![allow(unused)]
fn main() {
fn encode_selector(mut self: Bytes, selector: u32) -> Bytes
}

SolAbiEncodeU8

Encode int types Integers are encoded as 32 bytes long, which are right-aligned/left-padded Big-endian. Packed encodings are not padded and only append the bytes of the value based on type.

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeU8

#![allow(unused)]
fn main() {
pub impl SolAbiEncodeU8 of SolAbiEncodeTrait<u8>
}

Impl functions

encode

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeU8::encode

#![allow(unused)]
fn main() {
fn encode(mut self: Bytes, x: u8) -> Bytes
}

encode_packed

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeU8::encode_packed

#![allow(unused)]
fn main() {
fn encode_packed(mut self: Bytes, x: u8) -> Bytes
}

SolAbiEncodeU16

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeU16

#![allow(unused)]
fn main() {
pub impl SolAbiEncodeU16 of SolAbiEncodeTrait<u16>
}

Impl functions

encode

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeU16::encode

#![allow(unused)]
fn main() {
fn encode(mut self: Bytes, x: u16) -> Bytes
}

encode_packed

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeU16::encode_packed

#![allow(unused)]
fn main() {
fn encode_packed(mut self: Bytes, x: u16) -> Bytes
}

SolAbiEncodeU32

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeU32

#![allow(unused)]
fn main() {
pub impl SolAbiEncodeU32 of SolAbiEncodeTrait<u32>
}

Impl functions

encode

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeU32::encode

#![allow(unused)]
fn main() {
fn encode(mut self: Bytes, x: u32) -> Bytes
}

encode_packed

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeU32::encode_packed

#![allow(unused)]
fn main() {
fn encode_packed(mut self: Bytes, x: u32) -> Bytes
}

SolAbiEncodeU64

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeU64

#![allow(unused)]
fn main() {
pub impl SolAbiEncodeU64 of SolAbiEncodeTrait<u64>
}

Impl functions

encode

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeU64::encode

#![allow(unused)]
fn main() {
fn encode(mut self: Bytes, x: u64) -> Bytes
}

encode_packed

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeU64::encode_packed

#![allow(unused)]
fn main() {
fn encode_packed(mut self: Bytes, x: u64) -> Bytes
}

SolAbiEncodeU128

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeU128

#![allow(unused)]
fn main() {
pub impl SolAbiEncodeU128 of SolAbiEncodeTrait<u128>
}

Impl functions

encode

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeU128::encode

#![allow(unused)]
fn main() {
fn encode(mut self: Bytes, x: u128) -> Bytes
}

encode_packed

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeU128::encode_packed

#![allow(unused)]
fn main() {
fn encode_packed(mut self: Bytes, x: u128) -> Bytes
}

SolAbiEncodeU256

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeU256

#![allow(unused)]
fn main() {
pub impl SolAbiEncodeU256 of SolAbiEncodeTrait<u256>
}

Impl functions

encode

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeU256::encode

#![allow(unused)]
fn main() {
fn encode(mut self: Bytes, x: u256) -> Bytes
}

encode_packed

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeU256::encode_packed

#![allow(unused)]
fn main() {
fn encode_packed(mut self: Bytes, x: u256) -> Bytes
}

SolAbiEncodeBool

Encode other primitives Primitives are encoded as 32 bytes long, which are right-aligned/left-padded Big-endian. Packed encodings are not padded and only append the bytes of the value based on type.

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeBool

#![allow(unused)]
fn main() {
pub impl SolAbiEncodeBool of SolAbiEncodeTrait<bool>
}

Impl functions

encode

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeBool::encode

#![allow(unused)]
fn main() {
fn encode(mut self: Bytes, x: bool) -> Bytes
}

encode_packed

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeBool::encode_packed

#![allow(unused)]
fn main() {
fn encode_packed(mut self: Bytes, x: bool) -> Bytes
}

SolAbiEncodeFelt252

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeFelt252

#![allow(unused)]
fn main() {
pub impl SolAbiEncodeFelt252 of SolAbiEncodeTrait<felt252>
}

Impl functions

encode

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeFelt252::encode

#![allow(unused)]
fn main() {
fn encode(mut self: Bytes, x: felt252) -> Bytes
}

encode_packed

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeFelt252::encode_packed

#![allow(unused)]
fn main() {
fn encode_packed(mut self: Bytes, x: felt252) -> Bytes
}

SolAbiEncodeBytes31

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeBytes31

#![allow(unused)]
fn main() {
pub impl SolAbiEncodeBytes31 of SolAbiEncodeTrait<bytes31>
}

Impl functions

encode

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeBytes31::encode

#![allow(unused)]
fn main() {
fn encode(mut self: Bytes, x: bytes31) -> Bytes
}

encode_packed

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeBytes31::encode_packed

#![allow(unused)]
fn main() {
fn encode_packed(mut self: Bytes, x: bytes31) -> Bytes
}

SolAbiEncodeBytes

Encode byte types Bytes are encoded as 32 bytes long, which are left-aligned/right-padded. Packed encodings are not padded and only append the bytes up to the length of the value.

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeBytes

#![allow(unused)]
fn main() {
pub impl SolAbiEncodeBytes of SolAbiEncodeTrait<Bytes>
}

Impl functions

encode

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeBytes::encode

#![allow(unused)]
fn main() {
fn encode(mut self: Bytes, mut x: Bytes) -> Bytes
}

encode_packed

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeBytes::encode_packed

#![allow(unused)]
fn main() {
fn encode_packed(mut self: Bytes, x: Bytes) -> Bytes
}

SolAbiEncodeByteArray

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeByteArray

#![allow(unused)]
fn main() {
pub impl SolAbiEncodeByteArray of SolAbiEncodeTrait<ByteArray>
}

Impl functions

encode

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeByteArray::encode

#![allow(unused)]
fn main() {
fn encode(mut self: Bytes, x: ByteArray) -> Bytes
}

encode_packed

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeByteArray::encode_packed

#![allow(unused)]
fn main() {
fn encode_packed(mut self: Bytes, x: ByteArray) -> Bytes
}

SolAbiEncodeStarknetAddress

Encode address types Addresses are encoded as 32 bytes long, which are right-aligned/left-padded Big-endian. Packed encodings are not padded and only append the bytes of the value based on type.

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeStarknetAddress

#![allow(unused)]
fn main() {
pub impl SolAbiEncodeStarknetAddress of SolAbiEncodeTrait<ContractAddress>
}

Impl functions

encode

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeStarknetAddress::encode

#![allow(unused)]
fn main() {
fn encode(mut self: Bytes, x: ContractAddress) -> Bytes
}

encode_packed

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeStarknetAddress::encode_packed

#![allow(unused)]
fn main() {
fn encode_packed(mut self: Bytes, x: ContractAddress) -> Bytes
}

SolAbiEncodeEthAddress

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeEthAddress

#![allow(unused)]
fn main() {
pub impl SolAbiEncodeEthAddress of SolAbiEncodeTrait<EthAddress>
}

Impl functions

encode

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeEthAddress::encode

#![allow(unused)]
fn main() {
fn encode(mut self: Bytes, x: EthAddress) -> Bytes
}

encode_packed

Fully qualified path: alexandria_encoding::sol_abi::encode::SolAbiEncodeEthAddress::encode_packed

#![allow(unused)]
fn main() {
fn encode_packed(mut self: Bytes, x: EthAddress) -> Bytes
}

SolAbiEncodeAsU256

Encode as from int types Integers are encoded as byteSize bytes, which are right-aligned/left-padded Big-endian.

Fully qualified path: alexandria_encoding::sol_abi::encode_as::SolAbiEncodeAsU256

#![allow(unused)]
fn main() {
pub impl SolAbiEncodeAsU256 of SolAbiEncodeAsTrait<u256>
}

Impl functions

encode_as

Fully qualified path: alexandria_encoding::sol_abi::encode_as::SolAbiEncodeAsU256::encode_as

#![allow(unused)]
fn main() {
fn encode_as(mut self: Bytes, byteSize: usize, mut x: u256) -> Bytes
}

SolAbiEncodeAsU128

Fully qualified path: alexandria_encoding::sol_abi::encode_as::SolAbiEncodeAsU128

#![allow(unused)]
fn main() {
pub impl SolAbiEncodeAsU128 of SolAbiEncodeAsTrait<u128>
}

Impl functions

encode_as

Fully qualified path: alexandria_encoding::sol_abi::encode_as::SolAbiEncodeAsU128::encode_as

#![allow(unused)]
fn main() {
fn encode_as(mut self: Bytes, byteSize: usize, mut x: u128) -> Bytes
}

SolAbiEncodeAsFelt252

Fully qualified path: alexandria_encoding::sol_abi::encode_as::SolAbiEncodeAsFelt252

#![allow(unused)]
fn main() {
pub impl SolAbiEncodeAsFelt252 of SolAbiEncodeAsTrait<felt252>
}

Impl functions

encode_as

Fully qualified path: alexandria_encoding::sol_abi::encode_as::SolAbiEncodeAsFelt252::encode_as

#![allow(unused)]
fn main() {
fn encode_as(mut self: Bytes, byteSize: usize, x: felt252) -> Bytes
}

SolAbiEncodeAsBytes31

Fully qualified path: alexandria_encoding::sol_abi::encode_as::SolAbiEncodeAsBytes31

#![allow(unused)]
fn main() {
pub impl SolAbiEncodeAsBytes31 of SolAbiEncodeAsTrait<bytes31>
}

Impl functions

encode_as

Fully qualified path: alexandria_encoding::sol_abi::encode_as::SolAbiEncodeAsBytes31::encode_as

#![allow(unused)]
fn main() {
fn encode_as(mut self: Bytes, byteSize: usize, x: bytes31) -> Bytes
}

SolAbiEncodeAsBytes

Encode as from bytes types Bytes are encoded as byteSize bytes, which are left-aligned/right-padded.

Fully qualified path: alexandria_encoding::sol_abi::encode_as::SolAbiEncodeAsBytes

#![allow(unused)]
fn main() {
pub impl SolAbiEncodeAsBytes of SolAbiEncodeAsTrait<Bytes>
}

Impl functions

encode_as

Fully qualified path: alexandria_encoding::sol_abi::encode_as::SolAbiEncodeAsBytes::encode_as

#![allow(unused)]
fn main() {
fn encode_as(mut self: Bytes, byteSize: usize, x: Bytes) -> Bytes
}

SolAbiEncodeAsByteArray

Fully qualified path: alexandria_encoding::sol_abi::encode_as::SolAbiEncodeAsByteArray

#![allow(unused)]
fn main() {
pub impl SolAbiEncodeAsByteArray of SolAbiEncodeAsTrait<ByteArray>
}

Impl functions

encode_as

Fully qualified path: alexandria_encoding::sol_abi::encode_as::SolAbiEncodeAsByteArray::encode_as

#![allow(unused)]
fn main() {
fn encode_as(mut self: Bytes, byteSize: usize, x: ByteArray) -> Bytes
}

Alexandria Bytes

Fully qualified path: alexandria_data_structures

Modules

alexandria_data_structures

Fully qualified path: alexandria_data_structures

Modules

array_ext

Fully qualified path: alexandria_data_structures::array_ext

Traits

bit_array

Fully qualified path: alexandria_data_structures::bit_array

Free functions

Structs

Traits

byte_appender

Fully qualified path: alexandria_data_structures::byte_appender

Free functions

Traits

byte_array_ext

Fully qualified path: alexandria_data_structures::byte_array_ext

Impls

byte_reader

Fully qualified path: alexandria_data_structures::byte_reader

Structs

Traits

queue

Fully qualified path: alexandria_data_structures::queue

Structs

Traits

span_ext

Fully qualified path: alexandria_data_structures::span_ext

Traits

stack

Stack implementation. # Example

use alexandria::data_structures::stack::StackTrait;

// Create a new stack instance.
let mut stack = StackTrait::new();
// Create an item and push it to the stack.
let mut item:u256 = 1.into();
stack.push(item);
Remove the item from the stack;
let item = stack.pop();

Fully qualified path: alexandria_data_structures::stack

Structs

Traits

vec

Fully qualified path: alexandria_data_structures::vec

Structs

Traits

Free functions

shift_bit

Fully qualified path: alexandria_data_structures::bit_array::shift_bit

#![allow(unused)]
fn main() {
pub fn shift_bit(number: usize) -> u8
}

one_shift_left_bytes_felt252

Fully qualified path: alexandria_data_structures::bit_array::one_shift_left_bytes_felt252

#![allow(unused)]
fn main() {
pub fn one_shift_left_bytes_felt252(n_bytes: usize) -> felt252
}

one_shift_left_bytes_u128

Fully qualified path: alexandria_data_structures::bit_array::one_shift_left_bytes_u128

#![allow(unused)]
fn main() {
pub fn one_shift_left_bytes_u128(n_bytes: usize) -> u128
}

reversing

Fully qualified path: alexandria_data_structures::byte_appender::reversing

#![allow(unused)]
fn main() {
pub fn reversing<
    T,
    +Copy<T>,
    +Zero<T>,
    +TryInto<T, NonZero<T>>,
    +DivRem<T>,
    +Drop<T>,
    +MulAssign<T, T>,
    +Rem<T>,
    +AddAssign<T, T>,
>(
    word: T, size: usize, step: T,
) -> (T, T)
}

reversing_partial_result

Fully qualified path: alexandria_data_structures::byte_appender::reversing_partial_result

#![allow(unused)]
fn main() {
pub fn reversing_partial_result<
    T,
    +Copy<T>,
    +DivRem<T>,
    +TryInto<T, NonZero<T>>,
    +Drop<T>,
    +MulAssign<T, T>,
    +Rem<T>,
    +AddAssign<T, T>,
>(
    mut word: T, mut onto: T, size: usize, step: T,
) -> (T, T)
}

Structs

BitArray

Fully qualified path: alexandria_data_structures::bit_array::BitArray

#![allow(unused)]
fn main() {
#[derive(Clone, Drop)]
pub struct BitArray {
    data: Array<bytes31>,
    current: felt252,
    read_pos: usize,
    write_pos: usize,
}
}

ByteReaderState

Fully qualified path: alexandria_data_structures::byte_reader::ByteReaderState

#![allow(unused)]
fn main() {
#[derive(Clone, Drop)]
pub struct ByteReaderState<T> {
    pub(crate) data: @T,
    index: usize,
}
}

Queue

Fully qualified path: alexandria_data_structures::queue::Queue

#![allow(unused)]
fn main() {
pub struct Queue<T> {
    elements: Array<T>,
}
}

Felt252Stack

Fully qualified path: alexandria_data_structures::stack::Felt252Stack

#![allow(unused)]
fn main() {
pub struct Felt252Stack<T> {
    elements: Felt252Dict<T>,
    len: usize,
}
}

NullableStack

Fully qualified path: alexandria_data_structures::stack::NullableStack

#![allow(unused)]
fn main() {
pub struct NullableStack<T> {
    elements: Felt252Dict<Nullable<T>>,
    len: usize,
}
}

Felt252Vec

Fully qualified path: alexandria_data_structures::vec::Felt252Vec

#![allow(unused)]
fn main() {
pub struct Felt252Vec<T> {
    items: Felt252Dict<T>,
    len: usize,
}
}

NullableVec

Fully qualified path: alexandria_data_structures::vec::NullableVec

#![allow(unused)]
fn main() {
pub struct NullableVec<T> {
    items: Felt252Dict<Nullable<T>>,
    len: usize,
}
}

Traits

ArrayTraitExt

Fully qualified path: alexandria_data_structures::array_ext::ArrayTraitExt

#![allow(unused)]
fn main() {
pub trait ArrayTraitExt<T, +Clone<T>, +Drop<T>>
}

Trait functions

append_all

Moves all the elements of other into self, leaving other empty.

Arguments

  • self - The array to append elements to
  • other - The array to move elements from

Fully qualified path: alexandria_data_structures::array_ext::ArrayTraitExt::append_all

#![allow(unused)]
fn main() {
fn append_all(ref self: Array<T>, ref other: Array<T>)
}

extend_from_span

Clones and appends all the elements of other into self.

Arguments

  • self - The array to extend
  • other - The span containing elements to clone and append

Fully qualified path: alexandria_data_structures::array_ext::ArrayTraitExt::extend_from_span

#![allow(unused)]
fn main() {
fn extend_from_span(ref self: Array<T>, other: Span<T>)
}

pop_front_n

Removes up to n elements from the front of self and returns them in a new array.

Arguments

  • self - The array to remove elements from
  • n - The maximum number of elements to remove

Returns

  • Array<T> - New array containing the removed elements

Fully qualified path: alexandria_data_structures::array_ext::ArrayTraitExt::pop_front_n

#![allow(unused)]
fn main() {
fn pop_front_n(ref self: Array<T>, n: usize) -> Array<T>
}

remove_front_n

Removes up to n elements from the front of self.

Arguments

  • self - The array to remove elements from
  • n - The maximum number of elements to remove

Fully qualified path: alexandria_data_structures::array_ext::ArrayTraitExt::remove_front_n

#![allow(unused)]
fn main() {
fn remove_front_n(ref self: Array<T>, n: usize)
}

concat

Clones and appends all the elements of self and then other in a single new array.

Arguments

  • self - The first array to concatenate
  • other - The second array to concatenate

Returns

  • Array<T> - New array containing elements from both arrays

Fully qualified path: alexandria_data_structures::array_ext::ArrayTraitExt::concat

#![allow(unused)]
fn main() {
fn concat(self: @Array<T>, other: @Array<T>) -> Array<T>
}

reversed

Return a new array containing the elements of self in a reversed order.

Arguments

  • self - The array to reverse

Returns

  • Array<T> - New array with elements in reverse order

Fully qualified path: alexandria_data_structures::array_ext::ArrayTraitExt::reversed

#![allow(unused)]
fn main() {
fn reversed(self: @Array<T>) -> Array<T>
}

contains

Returns true if the array contains an element with the given value.

Arguments

  • self - The array to search
  • item - The item to search for

Returns

  • bool - True if the item is found, false otherwise

Fully qualified path: alexandria_data_structures::array_ext::ArrayTraitExt::contains

#![allow(unused)]
fn main() {
fn contains<+PartialEq<T>>(self: @Array<T>, item: @T) -> bool
}

position

Searches for an element in the array, returning its index.

Arguments

  • self - The array to search
  • item - The item to find the position of

Returns

  • Option<usize> - Some(index) if found, None otherwise

Fully qualified path: alexandria_data_structures::array_ext::ArrayTraitExt::position

#![allow(unused)]
fn main() {
fn position<+PartialEq<T>>(self: @Array<T>, item: @T) -> Option<usize>
}

occurrences

Returns the number of elements in the array with the given value.

Arguments

  • self - The array to search
  • item - The item to count occurrences of

Returns

  • usize - The number of times the item appears

Fully qualified path: alexandria_data_structures::array_ext::ArrayTraitExt::occurrences

#![allow(unused)]
fn main() {
fn occurrences<+PartialEq<T>>(self: @Array<T>, item: @T) -> usize
}

min

Returns the minimum element of an array.

Arguments

  • self - The array to find the minimum in

Returns

  • Option<T> - Some(min_element) if array is not empty, None otherwise

Fully qualified path: alexandria_data_structures::array_ext::ArrayTraitExt::min

#![allow(unused)]
fn main() {
fn min<+PartialOrd<@T>>(self: @Array<T>) -> Option<T>
}

min_position

Returns the position of the minimum element of an array.

Arguments

  • self - The array to find the minimum position in

Returns

  • Option<usize> - Some(index) of minimum element, None if array is empty

Fully qualified path: alexandria_data_structures::array_ext::ArrayTraitExt::min_position

#![allow(unused)]
fn main() {
fn min_position<+PartialOrd<@T>>(self: @Array<T>) -> Option<usize>
}

max

Returns the maximum element of an array.

Arguments

  • self - The array to find the maximum in

Returns

  • Option<T> - Some(max_element) if array is not empty, None otherwise

Fully qualified path: alexandria_data_structures::array_ext::ArrayTraitExt::max

#![allow(unused)]
fn main() {
fn max<+PartialOrd<@T>>(self: @Array<T>) -> Option<T>
}

max_position

Returns the position of the maximum element of an array.

Arguments

  • self - The array to find the maximum position in

Returns

  • Option<usize> - Some(index) of maximum element, None if array is empty

Fully qualified path: alexandria_data_structures::array_ext::ArrayTraitExt::max_position

#![allow(unused)]
fn main() {
fn max_position<+PartialOrd<@T>>(self: @Array<T>) -> Option<usize>
}

dedup

Returns a new array, cloned from self but removes consecutive repeated elements. If the array is sorted, this removes all duplicates.

Arguments

  • self - The array to deduplicate

Returns

  • Array<T> - New array with consecutive duplicates removed

Fully qualified path: alexandria_data_structures::array_ext::ArrayTraitExt::dedup

#![allow(unused)]
fn main() {
fn dedup<+PartialEq<T>>(self: @Array<T>) -> Array<T>
}

unique

Returns a new array, cloned from self but without any duplicate.

Arguments

  • self - The array to remove duplicates from

Returns

  • Array<T> - New array with all duplicates removed

Fully qualified path: alexandria_data_structures::array_ext::ArrayTraitExt::unique

#![allow(unused)]
fn main() {
fn unique<+PartialEq<T>>(self: @Array<T>) -> Array<T>
}

BitArrayTrait

Fully qualified path: alexandria_data_structures::bit_array::BitArrayTrait

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

Trait functions

new

Fully qualified path: alexandria_data_structures::bit_array::BitArrayTrait::new

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

current

Fully qualified path: alexandria_data_structures::bit_array::BitArrayTrait::current

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

data

Fully qualified path: alexandria_data_structures::bit_array::BitArrayTrait::data

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

append_bit

Appends a single bit to the BitArray

Arguments

  • bit - either true or false, representing a single bit to be appended

Fully qualified path: alexandria_data_structures::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

  • 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_data_structures::bit_array::BitArrayTrait::at

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

len

The current length of the BitArray

Returns

  • usize - length in bits of the BitArray

Fully qualified path: alexandria_data_structures::bit_array::BitArrayTrait::len

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

pop_front

Returns and removes the first element of the BitArray

Returns

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

Fully qualified path: alexandria_data_structures::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

  • 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_data_structures::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

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_data_structures::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

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_data_structures::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

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_data_structures::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

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_data_structures::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

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_data_structures::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

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_data_structures::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

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_data_structures::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

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_data_structures::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

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_data_structures::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

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_data_structures::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

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_data_structures::bit_array::BitArrayTrait::write_word_le_u512

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

ByteAppenderSupportTrait

Generic support trait for appending signed and unsigned integers onto byte storage. There are two functions, one for each of big and little endian byte order due to performance considerations. The byte reversal could be used in the naïve case when only one implementation is worthwhile.

Fully qualified path: alexandria_data_structures::byte_appender::ByteAppenderSupportTrait

#![allow(unused)]
fn main() {
pub trait ByteAppenderSupportTrait<T>
}

Trait functions

append_bytes_be

Appends bytes data of size count ordered in big endian

Arguments

  • bytes - big endian ordered bytes to append
  • count - number of bytes from input to append

Fully qualified path: alexandria_data_structures::byte_appender::ByteAppenderSupportTrait::append_bytes_be

#![allow(unused)]
fn main() {
fn append_bytes_be(ref self: T, bytes: felt252, count: usize)
}

append_bytes_le

Appends bytes data of size count ordered in little endian

Arguments

  • bytes - little endian ordered bytes to append
  • count - number of bytes from input to append

Fully qualified path: alexandria_data_structures::byte_appender::ByteAppenderSupportTrait::append_bytes_le

#![allow(unused)]
fn main() {
fn append_bytes_le(ref self: T, bytes: felt252, count: usize)
}

ByteAppender

Fully qualified path: alexandria_data_structures::byte_appender::ByteAppender

#![allow(unused)]
fn main() {
pub trait ByteAppender<T>
}

Trait functions

append_u16

Appends an unsigned 16 bit integer encoded in big endian

Arguments

  • word - a 16 bit unsigned integer typed as u16

Fully qualified path: alexandria_data_structures::byte_appender::ByteAppender::append_u16

#![allow(unused)]
fn main() {
fn append_u16(ref self: T, word: u16)
}

append_u16_le

Appends an unsigned 16 bit integer encoded in little endian

Arguments

  • word - a 16 bit unsigned integer typed as u16

Fully qualified path: alexandria_data_structures::byte_appender::ByteAppender::append_u16_le

#![allow(unused)]
fn main() {
fn append_u16_le(ref self: T, word: u16)
}

append_u32

Appends an unsigned 32 bit integer encoded in big endian

Arguments

  • word - a 32 bit unsigned integer typed as u32

Fully qualified path: alexandria_data_structures::byte_appender::ByteAppender::append_u32

#![allow(unused)]
fn main() {
fn append_u32(ref self: T, word: u32)
}

append_u32_le

Appends an unsigned 32 bit integer encoded in little endian

Arguments

  • word - a 32 bit unsigned integer typed as u32

Fully qualified path: alexandria_data_structures::byte_appender::ByteAppender::append_u32_le

#![allow(unused)]
fn main() {
fn append_u32_le(ref self: T, word: u32)
}

append_u64

Appends an unsigned 64 bit integer encoded in big endian

Arguments

  • word - a 64 bit unsigned integer typed as u64

Fully qualified path: alexandria_data_structures::byte_appender::ByteAppender::append_u64

#![allow(unused)]
fn main() {
fn append_u64(ref self: T, word: u64)
}

append_u64_le

Appends an unsigned 64 bit integer encoded in little endian

Arguments

  • word - a 64 bit unsigned integer typed as u64

Fully qualified path: alexandria_data_structures::byte_appender::ByteAppender::append_u64_le

#![allow(unused)]
fn main() {
fn append_u64_le(ref self: T, word: u64)
}

append_u128

Appends an unsigned 128 bit integer encoded in big endian

Arguments

  • word - a 128 bit unsigned integer typed as u128

Fully qualified path: alexandria_data_structures::byte_appender::ByteAppender::append_u128

#![allow(unused)]
fn main() {
fn append_u128(ref self: T, word: u128)
}

append_u128_le

Appends an unsigned 128 bit integer encoded in little endian

Arguments

  • word - a 128 bit unsigned integer typed as u128

Fully qualified path: alexandria_data_structures::byte_appender::ByteAppender::append_u128_le

#![allow(unused)]
fn main() {
fn append_u128_le(ref self: T, word: u128)
}

append_u256

Appends an unsigned 256 bit integer encoded in big endian

Arguments

  • word - a 256 bit unsigned integer typed as u256

Fully qualified path: alexandria_data_structures::byte_appender::ByteAppender::append_u256

#![allow(unused)]
fn main() {
fn append_u256(ref self: T, word: u256)
}

append_u256_le

Appends an unsigned 256 bit integer encoded in little endian

Arguments

  • word - a 256 bit unsigned integer typed as u256

Fully qualified path: alexandria_data_structures::byte_appender::ByteAppender::append_u256_le

#![allow(unused)]
fn main() {
fn append_u256_le(ref self: T, word: u256)
}

append_u512

Appends an unsigned 512 bit integer encoded in big endian

Arguments

  • word - a 512 bit unsigned integer typed as u32

Fully qualified path: alexandria_data_structures::byte_appender::ByteAppender::append_u512

#![allow(unused)]
fn main() {
fn append_u512(ref self: T, word: u512)
}

append_u512_le

Appends an unsigned 512 bit integer encoded in little endian

Arguments

  • word - a 512 bit unsigned integer typed as u32

Fully qualified path: alexandria_data_structures::byte_appender::ByteAppender::append_u512_le

#![allow(unused)]
fn main() {
fn append_u512_le(ref self: T, word: u512)
}

append_i8

Appends a signed 8 bit integer

Arguments

  • word - an 8 bit signed integer typed as i8

Fully qualified path: alexandria_data_structures::byte_appender::ByteAppender::append_i8

#![allow(unused)]
fn main() {
fn append_i8(ref self: T, word: i8)
}

append_i16

Appends a signed 16 bit integer encoded in big endian

Arguments

  • word - a 16 bit signed integer typed as i16

Fully qualified path: alexandria_data_structures::byte_appender::ByteAppender::append_i16

#![allow(unused)]
fn main() {
fn append_i16(ref self: T, word: i16)
}

append_i16_le

Appends a signed 16 bit integer encoded in little endian

Arguments

  • word - a 16 bit signed integer typed as i16

Fully qualified path: alexandria_data_structures::byte_appender::ByteAppender::append_i16_le

#![allow(unused)]
fn main() {
fn append_i16_le(ref self: T, word: i16)
}

append_i32

Appends a signed 32 bit integer encoded in big endian

Arguments

  • word - a 32 bit signed integer typed as i32

Fully qualified path: alexandria_data_structures::byte_appender::ByteAppender::append_i32

#![allow(unused)]
fn main() {
fn append_i32(ref self: T, word: i32)
}

append_i32_le

Appends a signed 32 bit integer encoded in little endian

Arguments

  • word - a 32 bit signed integer typed as i32

Fully qualified path: alexandria_data_structures::byte_appender::ByteAppender::append_i32_le

#![allow(unused)]
fn main() {
fn append_i32_le(ref self: T, word: i32)
}

append_i64

Appends a signed 64 bit integer encoded in big endian

Arguments

  • word - a 64 bit signed integer typed as i64

Fully qualified path: alexandria_data_structures::byte_appender::ByteAppender::append_i64

#![allow(unused)]
fn main() {
fn append_i64(ref self: T, word: i64)
}

append_i64_le

Appends a signed 64 bit integer encoded in little endian

Arguments

  • word - a 64 bit signed integer typed as i64

Fully qualified path: alexandria_data_structures::byte_appender::ByteAppender::append_i64_le

#![allow(unused)]
fn main() {
fn append_i64_le(ref self: T, word: i64)
}

append_i128

Appends a signed 128 bit integer encoded in big endian

Arguments

  • word - a 128 bit signed integer typed as i128

Fully qualified path: alexandria_data_structures::byte_appender::ByteAppender::append_i128

#![allow(unused)]
fn main() {
fn append_i128(ref self: T, word: i128)
}

append_i128_le

Appends a signed 128 bit integer encoded in little endian

Arguments

  • word - a 128 bit signed integer typed as i128

Fully qualified path: alexandria_data_structures::byte_appender::ByteAppender::append_i128_le

#![allow(unused)]
fn main() {
fn append_i128_le(ref self: T, word: i128)
}

ByteReader

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader

#![allow(unused)]
fn main() {
pub trait ByteReader<T>
}

Trait functions

reader

Wraps the array of bytes in a ByteReader for sequential consumption of integers and/or bytes

Returns

  • ByteReader - The reader struct wrapping a read-only snapshot of this ByteArray

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::reader

#![allow(unused)]
fn main() {
fn reader(self: @T) -> ByteReaderState<T>
}

remaining

Checks that there are enough remaining bytes available

Arguments

  • at - the start index position of the byte data
  • count - the number of bytes required

Returns

  • bool - true when there are count bytes remaining, false otherwise.

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::remaining

#![allow(unused)]
fn main() {
fn remaining(self: @T, at: usize, count: usize) -> bool
}

word_u16

Reads consecutive bytes from a specified offset as an unsigned integer in big endian

Arguments

  • offset - the start location of the consecutive bytes to read

Returns

  • Option<u16> - Returns an integer if there are enough consecutive bytes available in the ByteArray

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::word_u16

#![allow(unused)]
fn main() {
fn word_u16(self: @T, offset: usize) -> Option<u16>
}

word_u16_le

Reads consecutive bytes from a specified offset as an unsigned integer in little endian

Arguments

  • offset - the start location of the consecutive bytes to read

Returns

  • Option<u16> - Returns an integer if there are enough consecutive bytes available in the ByteArray

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::word_u16_le

#![allow(unused)]
fn main() {
fn word_u16_le(self: @T, offset: usize) -> Option<u16>
}

word_u32

Reads consecutive bytes from a specified offset as an unsigned integer in big endian

Arguments

  • offset - the start location of the consecutive bytes to read

Returns

  • Option<u32> - Returns an integer if there are enough consecutive bytes available in the ByteArray

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::word_u32

#![allow(unused)]
fn main() {
fn word_u32(self: @T, offset: usize) -> Option<u32>
}

word_u32_le

Reads consecutive bytes from a specified offset as an unsigned integer in little endian

Arguments

  • offset - the start location of the consecutive bytes to read

Returns

  • Option<u32> - Returns an integer if there are enough consecutive bytes available in the ByteArray

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::word_u32_le

#![allow(unused)]
fn main() {
fn word_u32_le(self: @T, offset: usize) -> Option<u32>
}

word_u64

Reads consecutive bytes from a specified offset as an unsigned integer in big endian

Arguments

  • offset - the start location of the consecutive bytes to read

Returns

  • Option<u64> - Returns an integer if there are enough consecutive bytes available in the ByteArray

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::word_u64

#![allow(unused)]
fn main() {
fn word_u64(self: @T, offset: usize) -> Option<u64>
}

word_u64_le

Reads consecutive bytes from a specified offset as an unsigned integer in little endian

Arguments

  • offset - the start location of the consecutive bytes to read

Returns

  • Option<u64> - Returns an integer if there are enough consecutive bytes available in the ByteArray

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::word_u64_le

#![allow(unused)]
fn main() {
fn word_u64_le(self: @T, offset: usize) -> Option<u64>
}

word_u128

Reads consecutive bytes from a specified offset as an unsigned integer in big endian

Arguments

  • offset - the start location of the consecutive bytes to read

Returns

  • Option<u128> - Returns an integer if there are enough consecutive bytes available in the ByteArray

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::word_u128

#![allow(unused)]
fn main() {
fn word_u128(self: @T, offset: usize) -> Option<u128>
}

word_u128_le

Reads consecutive bytes from a specified offset as an unsigned integer in little endian

Arguments

  • offset - the start location of the consecutive bytes to read

Returns

  • Option<u128> - Returns an integer if there are enough consecutive bytes available in the ByteArray

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::word_u128_le

#![allow(unused)]
fn main() {
fn word_u128_le(self: @T, offset: usize) -> Option<u128>
}

read_u8

Reads a u8 unsigned integer

Returns

  • Option<u8> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::read_u8

#![allow(unused)]
fn main() {
fn read_u8(ref self: ByteReaderState<T>) -> Option<u8>
}

read_u16

Reads a u16 unsigned integer in big endian byte order

Returns

  • Option<u16> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::read_u16

#![allow(unused)]
fn main() {
fn read_u16(ref self: ByteReaderState<T>) -> Option<u16>
}

read_u16_le

Reads a u16 unsigned integer in little endian byte order

Returns

  • Option<u16> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::read_u16_le

#![allow(unused)]
fn main() {
fn read_u16_le(ref self: ByteReaderState<T>) -> Option<u16>
}

read_u32

Reads a u32 unsigned integer in big endian byte order

Returns

  • Option<u32> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::read_u32

#![allow(unused)]
fn main() {
fn read_u32(ref self: ByteReaderState<T>) -> Option<u32>
}

read_u32_le

Reads a u32 unsigned integer in little endian byte order

Returns

  • Option<u32> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::read_u32_le

#![allow(unused)]
fn main() {
fn read_u32_le(ref self: ByteReaderState<T>) -> Option<u32>
}

read_u64

Reads a u64 unsigned integer in big endian byte order

Returns

  • Option<u64> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::read_u64

#![allow(unused)]
fn main() {
fn read_u64(ref self: ByteReaderState<T>) -> Option<u64>
}

read_u64_le

Reads a u64 unsigned integer in little endian byte order

Returns

  • Option<u64> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::read_u64_le

#![allow(unused)]
fn main() {
fn read_u64_le(ref self: ByteReaderState<T>) -> Option<u64>
}

read_u128

Reads a u128 unsigned integer in big endian byte order

Returns

  • Option<u128> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::read_u128

#![allow(unused)]
fn main() {
fn read_u128(ref self: ByteReaderState<T>) -> Option<u128>
}

read_u128_le

Reads a u128 unsigned integer in little endian byte order

Returns

  • Option<u128> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::read_u128_le

#![allow(unused)]
fn main() {
fn read_u128_le(ref self: ByteReaderState<T>) -> Option<u128>
}

read_u256

Reads a u256 unsigned integer in big endian byte order

Returns

  • Option<u256> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::read_u256

#![allow(unused)]
fn main() {
fn read_u256(ref self: ByteReaderState<T>) -> Option<u256>
}

read_u256_le

Reads a u256 unsigned integer in little endian byte order

Returns

  • Option<u256> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::read_u256_le

#![allow(unused)]
fn main() {
fn read_u256_le(ref self: ByteReaderState<T>) -> Option<u256>
}

read_u512

Reads a u512 unsigned integer in big endian byte order

Returns

  • Option<u512> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::read_u512

#![allow(unused)]
fn main() {
fn read_u512(ref self: ByteReaderState<T>) -> Option<u512>
}

read_u512_le

Reads a u512 unsigned integer in little endian byte order

Returns

  • Option<u512> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::read_u512_le

#![allow(unused)]
fn main() {
fn read_u512_le(ref self: ByteReaderState<T>) -> Option<u512>
}

read_i8

Reads an i8 signed integer in two's complement encoding from the ByteArray

Returns

  • Option<i8> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::read_i8

#![allow(unused)]
fn main() {
fn read_i8(ref self: ByteReaderState<T>) -> Option<i8>
}

read_i16

Reads an i16 signed integer in two's complement encoding from the ByteArray in big endian byte order

Returns

  • Option<i16> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::read_i16

#![allow(unused)]
fn main() {
fn read_i16(ref self: ByteReaderState<T>) -> Option<i16>
}

read_i16_le

Reads an i16 signed integer in two's complement encoding from the ByteArray in little endian byte order

Returns

  • Option<i16> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::read_i16_le

#![allow(unused)]
fn main() {
fn read_i16_le(ref self: ByteReaderState<T>) -> Option<i16>
}

read_i32

Reads an i32 signed integer in two's complement encoding from the ByteArray in big endian byte order

Returns

  • Option<i32> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::read_i32

#![allow(unused)]
fn main() {
fn read_i32(ref self: ByteReaderState<T>) -> Option<i32>
}

read_i32_le

Reads an i32 signed integer in two's complement encoding from the ByteArray in little endian byte order

Returns

  • Option<i32> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::read_i32_le

#![allow(unused)]
fn main() {
fn read_i32_le(ref self: ByteReaderState<T>) -> Option<i32>
}

read_i64

Reads an i64 signed integer in two's complement encoding from the ByteArray in big endian byte order

Returns

  • Option<i64> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::read_i64

#![allow(unused)]
fn main() {
fn read_i64(ref self: ByteReaderState<T>) -> Option<i64>
}

read_i64_le

Reads an i64 signed integer in two's complement encoding from the ByteArray in little endian byte order

Returns

  • Option<i64> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::read_i64_le

#![allow(unused)]
fn main() {
fn read_i64_le(ref self: ByteReaderState<T>) -> Option<i64>
}

read_i128

Reads an i128 signed integer in two's complement encoding from the ByteArray in big endian byte order

Returns

  • Option<i128> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::read_i128

#![allow(unused)]
fn main() {
fn read_i128(ref self: ByteReaderState<T>) -> Option<i128>
}

read_i128_le

Reads an i128 signed integer in two's complement encoding from the ByteArray in little endian byte order

Returns

  • Option<i128> - If there are enough bytes remaining an optional integer is returned

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::read_i128_le

#![allow(unused)]
fn main() {
fn read_i128_le(ref self: ByteReaderState<T>) -> Option<i128>
}

len

Remaining length count relative to what has already been consume/read

Returns

  • usize - count number of bytes remaining

Fully qualified path: alexandria_data_structures::byte_reader::ByteReader::len

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

QueueTrait

Fully qualified path: alexandria_data_structures::queue::QueueTrait

#![allow(unused)]
fn main() {
pub trait QueueTrait<T>
}

Trait functions

new

Creates a new empty queue

Returns

  • Queue<T> - A new empty queue instance

Fully qualified path: alexandria_data_structures::queue::QueueTrait::new

#![allow(unused)]
fn main() {
fn new() -> Queue<T>
}

enqueue

Adds an element to the back of the queue

Arguments

  • self - The queue to add the element to
  • value - The element to add

Fully qualified path: alexandria_data_structures::queue::QueueTrait::enqueue

#![allow(unused)]
fn main() {
fn enqueue(ref self: Queue<T>, value: T)
}

dequeue

Removes and returns the front element from the queue

Arguments

  • self - The queue to remove the element from

Returns

  • Option<T> - Some(element) if queue is not empty, None otherwise

Fully qualified path: alexandria_data_structures::queue::QueueTrait::dequeue

#![allow(unused)]
fn main() {
fn dequeue(ref self: Queue<T>) -> Option<T>
}

peek_front

Returns a reference to the front element without removing it

Arguments

  • self - The queue to peek into

Returns

  • Option<Box<@T>> - Some(reference) to front element if queue is not empty, None otherwise

Fully qualified path: alexandria_data_structures::queue::QueueTrait::peek_front

#![allow(unused)]
fn main() {
fn peek_front(self: @Queue<T>) -> Option<Box<@T>>
}

len

Returns the number of elements in the queue

Arguments

  • self - The queue to get the length of

Returns

  • usize - The number of elements in the queue

Fully qualified path: alexandria_data_structures::queue::QueueTrait::len

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

is_empty

Checks if the queue is empty

Arguments

  • self - The queue to check

Returns

  • bool - True if the queue contains no elements, false otherwise

Fully qualified path: alexandria_data_structures::queue::QueueTrait::is_empty

#![allow(unused)]
fn main() {
fn is_empty(self: @Queue<T>) -> bool
}

SpanTraitExt

Fully qualified path: alexandria_data_structures::span_ext::SpanTraitExt

#![allow(unused)]
fn main() {
pub trait SpanTraitExt<T, +Clone<T>, +Drop<T>>
}

Trait functions

pop_front_n

Removes up to n elements from the front of self and returns them in a new span.

Arguments

  • self - The span to modify
  • n - The number of elements to remove from the front

Fully qualified path: alexandria_data_structures::span_ext::SpanTraitExt::pop_front_n

#![allow(unused)]
fn main() {
fn pop_front_n(ref self: Span<T>, n: usize) -> Span<T>
}

pop_back_n

Removes up to n elements from the back of self and returns them in a new span.

Arguments

  • self - The span to modify
  • n - The number of elements to remove from the back

Fully qualified path: alexandria_data_structures::span_ext::SpanTraitExt::pop_back_n

#![allow(unused)]
fn main() {
fn pop_back_n(ref self: Span<T>, n: usize) -> Span<T>
}

remove_front_n

Removes up to n elements from the front of self.

Arguments

  • self - The span to modify
  • n - The number of elements to remove from the front

Fully qualified path: alexandria_data_structures::span_ext::SpanTraitExt::remove_front_n

#![allow(unused)]
fn main() {
fn remove_front_n(ref self: Span<T>, n: usize)
}

remove_back_n

Removes up to n elements from the back of self.

Arguments

  • self - The span to modify
  • n - The number of elements to remove from the back

Fully qualified path: alexandria_data_structures::span_ext::SpanTraitExt::remove_back_n

#![allow(unused)]
fn main() {
fn remove_back_n(ref self: Span<T>, n: usize)
}

concat

Clones and appends all the elements of self and then other in a single new array.

Arguments

  • self - The first span to concatenate
  • other - The second span to concatenate

Fully qualified path: alexandria_data_structures::span_ext::SpanTraitExt::concat

#![allow(unused)]
fn main() {
fn concat(self: Span<T>, other: Span<T>) -> Array<T>
}

reversed

Return a new array containing the elements of self in a reversed order.

Arguments

  • self - The span to reverse

Fully qualified path: alexandria_data_structures::span_ext::SpanTraitExt::reversed

#![allow(unused)]
fn main() {
fn reversed(self: Span<T>) -> Array<T>
}

contains

Returns true if the span contains an element with the given value.

Arguments

  • self - The span to search
  • item - The value to search for

Fully qualified path: alexandria_data_structures::span_ext::SpanTraitExt::contains

#![allow(unused)]
fn main() {
fn contains<+PartialEq<T>>(self: Span<T>, item: @T) -> bool
}

position

Searches for an element the span, returning its index.

Arguments

  • self - The span to search
  • item - The value to search for

Fully qualified path: alexandria_data_structures::span_ext::SpanTraitExt::position

#![allow(unused)]
fn main() {
fn position<+PartialEq<T>>(self: Span<T>, item: @T) -> Option<usize>
}

occurrences

Returns the number of elements in the span with the given value.

Arguments

  • self - The span to search
  • item - The value to count

Fully qualified path: alexandria_data_structures::span_ext::SpanTraitExt::occurrences

#![allow(unused)]
fn main() {
fn occurrences<+PartialEq<T>>(self: Span<T>, item: @T) -> usize
}

min

Returns the minimum element of a span.

Arguments

  • self - The span to find the minimum value in

Fully qualified path: alexandria_data_structures::span_ext::SpanTraitExt::min

#![allow(unused)]
fn main() {
fn min<+PartialOrd<@T>>(self: Span<T>) -> Option<T>
}

min_position

Returns the position of the minimum element of a span.

Arguments

  • self - The span to find the minimum position in

Fully qualified path: alexandria_data_structures::span_ext::SpanTraitExt::min_position

#![allow(unused)]
fn main() {
fn min_position<+PartialOrd<@T>>(self: Span<T>) -> Option<usize>
}

max

Returns the maximum element of a span.

Arguments

  • self - The span to find the maximum value in

Fully qualified path: alexandria_data_structures::span_ext::SpanTraitExt::max

#![allow(unused)]
fn main() {
fn max<+PartialOrd<@T>>(self: Span<T>) -> Option<T>
}

max_position

Returns the position of the maximum element of a span.

Arguments

  • self - The span to find the maximum position in

Fully qualified path: alexandria_data_structures::span_ext::SpanTraitExt::max_position

#![allow(unused)]
fn main() {
fn max_position<+PartialOrd<@T>>(self: Span<T>) -> Option<usize>
}

dedup

Returns a new array, cloned from self but removes consecutive repeated elements. If the span is sorted, this removes all duplicates.

Arguments

  • self - The span to deduplicate

Fully qualified path: alexandria_data_structures::span_ext::SpanTraitExt::dedup

#![allow(unused)]
fn main() {
fn dedup<+PartialEq<T>>(self: Span<T>) -> Array<T>
}

unique

Returns a new array, cloned from self but without any duplicate.

Arguments

  • self - The span to get unique elements from

Fully qualified path: alexandria_data_structures::span_ext::SpanTraitExt::unique

#![allow(unused)]
fn main() {
fn unique<+PartialEq<T>>(self: Span<T>) -> Array<T>
}

StackTrait

Fully qualified path: alexandria_data_structures::stack::StackTrait

#![allow(unused)]
fn main() {
pub trait StackTrait<S, T>
}

Trait functions

new

Creates a new Stack instance.

Fully qualified path: alexandria_data_structures::stack::StackTrait::new

#![allow(unused)]
fn main() {
fn new() -> S
}

push

Pushes a new value onto the stack.

Arguments

  • self - The stack to push the value onto
  • value - The value to push onto the stack

Fully qualified path: alexandria_data_structures::stack::StackTrait::push

#![allow(unused)]
fn main() {
fn push(ref self: S, value: T)
}

pop

Removes the last item from the stack and returns it, or None if the stack is empty.

Arguments

  • self - The stack to pop the item from

Fully qualified path: alexandria_data_structures::stack::StackTrait::pop

#![allow(unused)]
fn main() {
fn pop(ref self: S) -> Option<T>
}

peek

Returns the last item from the stack without removing it, or None if the stack is empty.

Arguments

  • self - The stack to peek at

Fully qualified path: alexandria_data_structures::stack::StackTrait::peek

#![allow(unused)]
fn main() {
fn peek(ref self: S) -> Option<T>
}

len

Returns the number of items in the stack.

Arguments

  • self - The stack to get the length of

Fully qualified path: alexandria_data_structures::stack::StackTrait::len

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

is_empty

Returns true if the stack is empty.

Arguments

  • self - The stack to check if it is empty

Fully qualified path: alexandria_data_structures::stack::StackTrait::is_empty

#![allow(unused)]
fn main() {
fn is_empty(self: @S) -> bool
}

VecTrait

Fully qualified path: alexandria_data_structures::vec::VecTrait

#![allow(unused)]
fn main() {
pub trait VecTrait<V, T>
}

Trait functions

new

Creates a new V instance. Returns * V The new vec instance.

Fully qualified path: alexandria_data_structures::vec::VecTrait::new

#![allow(unused)]
fn main() {
fn new() -> V
}

get

Returns the item at the given index, or None if the index is out of bounds. Parameters * self The vec instance. * index The index of the item to get. Returns * Option The item at the given index, or None if the index is out of bounds.

Fully qualified path: alexandria_data_structures::vec::VecTrait::get

#![allow(unused)]
fn main() {
fn get(ref self: V, index: usize) -> Option<T>
}

at

Returns the item at the given index, or panics if the index is out of bounds. Parameters * self The vec instance. * index The index of the item to get. Returns * T The item at the given index.

Fully qualified path: alexandria_data_structures::vec::VecTrait::at

#![allow(unused)]
fn main() {
fn at(ref self: V, index: usize) -> T
}

push

Pushes a new item to the vec. Parameters * self The vec instance. * value The value to push onto the vec.

Fully qualified path: alexandria_data_structures::vec::VecTrait::push

#![allow(unused)]
fn main() {
fn push(ref self: V, value: T)
}

set

Sets the item at the given index to the given value. Panics if the index is out of bounds. Parameters * self The vec instance. * index The index of the item to set. * value The value to set the item to.

Fully qualified path: alexandria_data_structures::vec::VecTrait::set

#![allow(unused)]
fn main() {
fn set(ref self: V, index: usize, value: T)
}

len

Returns the length of the vec. Parameters * self The vec instance. Returns * usize The length of the vec.

Fully qualified path: alexandria_data_structures::vec::VecTrait::len

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

Impls

SpanU8IntoBytearray

Fully qualified path: alexandria_data_structures::byte_array_ext::SpanU8IntoBytearray

#![allow(unused)]
fn main() {
pub impl SpanU8IntoBytearray of Into<Span<u8>, ByteArray>
}

Impl functions

into

Fully qualified path: alexandria_data_structures::byte_array_ext::SpanU8IntoBytearray::into

#![allow(unused)]
fn main() {
fn into(self: Span<u8>) -> ByteArray
}

ByteArrayIntoArrayU8

Fully qualified path: alexandria_data_structures::byte_array_ext::ByteArrayIntoArrayU8

#![allow(unused)]
fn main() {
pub impl ByteArrayIntoArrayU8 of Into<ByteArray, Array<u8>>
}

Impl functions

into

Fully qualified path: alexandria_data_structures::byte_array_ext::ByteArrayIntoArrayU8::into

#![allow(unused)]
fn main() {
fn into(self: ByteArray) -> Array<u8>
}

Alexandria Evm

Fully qualified path: alexandria_evm

Modules

alexandria_evm

Fully qualified path: alexandria_evm

Alexandria Linalg

Fully qualified path: alexandria_linalg

Modules

alexandria_linalg

Fully qualified path: alexandria_linalg

Modules

dot

Fully qualified path: alexandria_linalg::dot

Free functions

kron

Kronecker product of two arrays

Fully qualified path: alexandria_linalg::kron

Free functions

Enums

norm

Norm of an T array.

Fully qualified path: alexandria_linalg::norm

Free functions

Free functions

dot

Compute the dot product for 2 given arrays.

Arguments

  • xs - The first sequence of len L.
  • ys - The second sequence of len L.

Returns

  • sum - The dot product.

Fully qualified path: alexandria_linalg::dot::dot

#![allow(unused)]
fn main() {
pub fn dot<T, +Mul<T>, +AddAssign<T, T>, +Zero<T>, +Copy<T>, +Drop<T>>(
    mut xs: Span<T>, mut ys: Span<T>,
) -> T
}

kron

Compute the Kronecker product for 2 given arrays.

Arguments

  • xs - The first sequence of len L.
  • ys - The second sequence of len L.

Returns

  • Result<Array<T>, KronError> - The Kronecker product.

Fully qualified path: alexandria_linalg::kron::kron

#![allow(unused)]
fn main() {
pub fn kron<T, +Mul<T>, +Copy<T>, +Drop<T>>(
    mut xs: Span<T>, mut ys: Span<T>,
) -> Result<Array<T>, KronError>
}

norm

Compute the norm for an T array.

Arguments

  • array - The inputted array.
  • ord - The order of the norm.
  • iter - The number of iterations to run the algorithm

Returns

  • u128 - The norm for the array.

Fully qualified path: alexandria_linalg::norm::norm

#![allow(unused)]
fn main() {
pub fn norm<T, +Into<T, u128>, +Zero<T>, +Copy<T>, +Drop<T>>(
    mut xs: Span<T>, ord: u128, iter: usize,
) -> u128
}

Enums

KronError

Fully qualified path: alexandria_linalg::kron::KronError

#![allow(unused)]
fn main() {
#[derive(Drop, Copy, PartialEq)]
pub enum KronError {
    UnequalLength,
}
}

Variants

UnequalLength

Fully qualified path: alexandria_linalg::kron::KronError::UnequalLength

#![allow(unused)]
fn main() {
UnequalLength
}

Alexandria Math

Fully qualified path: alexandria_math

Modules

alexandria_math

Fully qualified path: alexandria_math

aliquot_sum

Aliquot Sum

Fully qualified path: alexandria_math::aliquot_sum

Free functions

armstrong_number

Armstrong Number Algorithm.

Fully qualified path: alexandria_math::armstrong_number

Free functions

bip340

bip340 implementation

Fully qualified path: alexandria_math::bip340

Free functions

bitmap

Fully qualified path: alexandria_math::bitmap

Traits

collatz_sequence

Collatz Sequence

Fully qualified path: alexandria_math::collatz_sequence

Free functions

const_pow

Fully qualified path: alexandria_math::const_pow

Free functions

ed25519

Fully qualified path: alexandria_math::ed25519

Constants

Free functions

Structs

Traits

extended_euclidean_algorithm

Extended Euclidean Algorithm.

Fully qualified path: alexandria_math::extended_euclidean_algorithm

Free functions

fast_power

Fast power algorithm

Fully qualified path: alexandria_math::fast_power

Free functions

fast_root

Fast root algorithm using the Newton-Raphson method

Fully qualified path: alexandria_math::fast_root

Free functions

fibonacci

Fully qualified path: alexandria_math::fibonacci

Free functions

gcd_of_n_numbers

GCD for N numbers

Fully qualified path: alexandria_math::gcd_of_n_numbers

Free functions

i257

Fully qualified path: alexandria_math::i257

Free functions

Structs

Traits

Impls

is_power_of_two

Fully qualified path: alexandria_math::is_power_of_two

Free functions

is_prime

Fully qualified path: alexandria_math::is_prime

Free functions

karatsuba

Karatsuba Multiplication.

Fully qualified path: alexandria_math::karatsuba

Free functions

keccak256

Fully qualified path: alexandria_math::keccak256

Free functions

lcm_of_n_numbers

LCM for N numbers

Fully qualified path: alexandria_math::lcm_of_n_numbers

Free functions

Enums

mod_arithmetics

Fully qualified path: alexandria_math::mod_arithmetics

Free functions

perfect_number

Perfect Number.

Fully qualified path: alexandria_math::perfect_number

Free functions

sha256

Fully qualified path: alexandria_math::sha256

Free functions

sha512

Fully qualified path: alexandria_math::sha512

Constants

Free functions

Structs

Traits

Impls

trigonometry

Fully qualified path: alexandria_math::trigonometry

Free functions

u512_arithmetics

Fully qualified path: alexandria_math::u512_arithmetics

Free functions

Structs

Impls

wad_ray_math

Fully qualified path: alexandria_math::wad_ray_math

Free functions

zellers_congruence

Zeller's congruence is an algorithm devised by Christian Zeller in the 19th century to calculate the day of the week for any Julian or Gregorian calendar date. It can be considered to be based on the conversion between Julian day and the calendar date.

Fully qualified path: alexandria_math::zellers_congruence

Free functions

Constants

p

Fully qualified path: alexandria_math::ed25519::p

#![allow(unused)]
fn main() {
pub const p: u256 = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed;
}

p_non_zero

Fully qualified path: alexandria_math::ed25519::p_non_zero

#![allow(unused)]
fn main() {
pub const p_non_zero: NonZero<u256> =
    0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed;
}

p2x

Fully qualified path: alexandria_math::ed25519::p2x

#![allow(unused)]
fn main() {
pub const p2x: u256 = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffda;
}

a

Fully qualified path: alexandria_math::ed25519::a

#![allow(unused)]
fn main() {
pub const a: u256 = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec;
}

c

Fully qualified path: alexandria_math::ed25519::c

#![allow(unused)]
fn main() {
pub const c: u256 = 3;
}

d

Fully qualified path: alexandria_math::ed25519::d

#![allow(unused)]
fn main() {
pub const d: u256 = 0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3;
}

d2x

Fully qualified path: alexandria_math::ed25519::d2x

#![allow(unused)]
fn main() {
pub const d2x: u256 = 0xa406d9dc56dffce7198e80f2eef3d13000e0149a8283b156ebd69b9426b2f146;
}

l

Fully qualified path: alexandria_math::ed25519::l

#![allow(unused)]
fn main() {
pub const l: u256 = 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed;
}

w

Fully qualified path: alexandria_math::ed25519::w

#![allow(unused)]
fn main() {
pub const w: u256 = 4;
}

SHA512_LEN

Fully qualified path: alexandria_math::sha512::SHA512_LEN

#![allow(unused)]
fn main() {
pub const SHA512_LEN: usize = 64;
}

U64_BIT_NUM

Fully qualified path: alexandria_math::sha512::U64_BIT_NUM

#![allow(unused)]
fn main() {
pub const U64_BIT_NUM: u64 = 64;
}

TWO_POW_56

Fully qualified path: alexandria_math::sha512::TWO_POW_56

#![allow(unused)]
fn main() {
pub const TWO_POW_56: u64 = 0x100000000000000;
}

TWO_POW_48

Fully qualified path: alexandria_math::sha512::TWO_POW_48

#![allow(unused)]
fn main() {
pub const TWO_POW_48: u64 = 0x1000000000000;
}

TWO_POW_40

Fully qualified path: alexandria_math::sha512::TWO_POW_40

#![allow(unused)]
fn main() {
pub const TWO_POW_40: u64 = 0x10000000000;
}

TWO_POW_32

Fully qualified path: alexandria_math::sha512::TWO_POW_32

#![allow(unused)]
fn main() {
pub const TWO_POW_32: u64 = 0x100000000;
}

TWO_POW_24

Fully qualified path: alexandria_math::sha512::TWO_POW_24

#![allow(unused)]
fn main() {
pub const TWO_POW_24: u64 = 0x1000000;
}

TWO_POW_16

Fully qualified path: alexandria_math::sha512::TWO_POW_16

#![allow(unused)]
fn main() {
pub const TWO_POW_16: u64 = 0x10000;
}

TWO_POW_8

Fully qualified path: alexandria_math::sha512::TWO_POW_8

#![allow(unused)]
fn main() {
pub const TWO_POW_8: u64 = 0x100;
}

TWO_POW_4

Fully qualified path: alexandria_math::sha512::TWO_POW_4

#![allow(unused)]
fn main() {
pub const TWO_POW_4: u64 = 0x10;
}

TWO_POW_2

Fully qualified path: alexandria_math::sha512::TWO_POW_2

#![allow(unused)]
fn main() {
pub const TWO_POW_2: u64 = 0x4;
}

TWO_POW_1

Fully qualified path: alexandria_math::sha512::TWO_POW_1

#![allow(unused)]
fn main() {
pub const TWO_POW_1: u64 = 0x2;
}

TWO_POW_0

Fully qualified path: alexandria_math::sha512::TWO_POW_0

#![allow(unused)]
fn main() {
pub const TWO_POW_0: u64 = 0x1;
}

MAX_U8

Fully qualified path: alexandria_math::sha512::MAX_U8

#![allow(unused)]
fn main() {
pub const MAX_U8: u64 = 0xff;
}

MAX_U64

Fully qualified path: alexandria_math::sha512::MAX_U64

#![allow(unused)]
fn main() {
pub const MAX_U64: u128 = 0xffffffffffffffff;
}

Free functions

pow

Raise a number to a power. O(log n) time complexity. * base - The number to raise. * exp - The exponent.

Returns

  • T - The result of base raised to the power of exp.

Fully qualified path: alexandria_math::pow

#![allow(unused)]
fn main() {
pub fn pow<T, +Sub<T>, +Mul<T>, +Div<T>, +Rem<T>, +PartialEq<T>, +Into<u8, T>, +Drop<T>, +Copy<T>>(
    base: T, exp: T,
) -> T
}

aliquot_sum

Calculates the aliquot sum of a given number.

Arguments

  • number - The number to calculate the aliquot sum for.

Returns

  • felt252 - The aliquot sum of the input number.

Fully qualified path: alexandria_math::aliquot_sum::aliquot_sum

#![allow(unused)]
fn main() {
pub fn aliquot_sum(number: u128) -> u128
}

is_armstrong_number

Armstrong Number Algorithm.

Arguments

  • num - The number to be evaluated.

Returns

  • bool - A boolean value indicating is Armstrong Number.

Fully qualified path: alexandria_math::armstrong_number::is_armstrong_number

#![allow(unused)]
fn main() {
pub fn is_armstrong_number(mut num: u128) -> bool
}

verify

Verifies a signature according to the BIP-340.This function checks if the signature (rx, s) is valid for a message m with respect to the public key px.

Arguments

  • px: u256 - The x-coordinate of the public key.
  • rx: u256 - The x-coordinate of the R point from the signature.
  • s: u256 - The scalar component of the signature.
  • m: ByteArray - The message for which the signature is being verified.

Returns

  • bool - true if the signature is verified for the message and public key, false otherwise.

Fully qualified path: alexandria_math::bip340::verify

#![allow(unused)]
fn main() {
pub fn verify(px: u256, rx: u256, s: u256, m: ByteArray) -> bool
}

sequence

Generates the Collatz sequence for a given number.

Arguments

  • number - The number to generate the Collatz sequence for.

Returns

  • Array - The Collatz sequence as an array of felt252 numbers.

Fully qualified path: alexandria_math::collatz_sequence::sequence

#![allow(unused)]
fn main() {
pub fn sequence(mut number: u128) -> Array<u128>
}

pow2_u256

Calculate 2 raised to the power of the given exponent using a pre-computed lookup table

Arguments

  • exponent - The exponent to raise 2 to

Returns

  • u256 - The result of 2^exponent

Panics

  • If exponent is greater than 255 (out of the supported range)

Fully qualified path: alexandria_math::const_pow::pow2_u256

#![allow(unused)]
fn main() {
pub fn pow2_u256(exponent: u32) -> u256
}

pow2

Calculate 2 raised to the power of the given exponent using a pre-computed lookup table

Arguments

  • exponent - The exponent to raise 2 to

Returns

  • u128 - The result of 2^exponent

Panics

  • If exponent is greater than 127 (out of the supported range)

Fully qualified path: alexandria_math::const_pow::pow2

#![allow(unused)]
fn main() {
pub fn pow2(exponent: u32) -> u128
}

pow2_felt252

Calculate 2 raised to the power of the given exponent using a pre-computed lookup table

Arguments

  • exponent - The exponent to raise 2 to

Returns

  • felt252 - The result of 2^exponent

Panics

  • If exponent is greater than 251 (out of the supported range)

Fully qualified path: alexandria_math::const_pow::pow2_felt252

#![allow(unused)]
fn main() {
pub fn pow2_felt252(exponent: u32) -> felt252
}

pow10

Calculate 10 raised to the power of the given exponent using a pre-computed lookup table

Arguments

  • exponent - The exponent to raise 10 to

Returns

  • u128 - The result of 10^exponent

Panics

  • If exponent is greater than 38 (out of the supported range)

Fully qualified path: alexandria_math::const_pow::pow10

#![allow(unused)]
fn main() {
pub fn pow10(exponent: u32) -> u128
}

pow10_u256

Calculate 10 raised to the power of the given exponent using a pre-computed lookup table

Arguments

  • exponent - The exponent to raise 10 to

Returns

  • u128 - The result of 10^exponent

Panics

  • If exponent is greater than 77 (out of the supported range)

Fully qualified path: alexandria_math::const_pow::pow10_u256

#![allow(unused)]
fn main() {
pub fn pow10_u256(exponent: u32) -> u256
}

point_mult_double_and_add

Function that performs point multiplication for an Elliptic Curve point using the double and add method.

Arguments

  • scalar - Scalar such that scalar * P = P + P + P + ... + P.
  • P - Elliptic Curve point
  • prime_nz - Field prime in NonZero form.

Returns

  • u256 - Resulting point

Fully qualified path: alexandria_math::ed25519::point_mult_double_and_add

#![allow(unused)]
fn main() {
pub fn point_mult_double_and_add(mut scalar: u256, mut P: Point, prime_nz: NonZero<u256>) -> Point
}

verify_signature

Experimental feature: use with caution. Not recommended for production. Verifies an Ed25519 signature against a message and public key.

Arguments

  • msg - The message that was signed as a span of bytes
  • signature - The signature as a span of two u256 values [R, S](R, S)
  • pub_key - The public key as a u256 value

Returns

  • bool - true if the signature is valid, false otherwise

Fully qualified path: alexandria_math::ed25519::verify_signature

#![allow(unused)]
fn main() {
pub fn verify_signature(msg: Span<u8>, signature: Span<u256>, pub_key: u256) -> bool
}

extended_euclidean_algorithm

Extended Euclidean Algorithm.

Arguments

  • a - First number.
  • b - Second number.

Returns

  • gcd - Greatest common divisor.
  • x - First Bezout coefficient.
  • y - Second Bezout coefficient.

Fully qualified path: alexandria_math::extended_euclidean_algorithm::extended_euclidean_algorithm

#![allow(unused)]
fn main() {
pub fn extended_euclidean_algorithm(a: u128, b: u128) -> (u128, u128, u128)
}

fast_power

Calculate the base ^ power using the fast powering algorithm

Arguments

  • base - The base of the exponentiation
  • power - The power of the exponentiation

Returns

  • T - The result of base ^ power

Panics

  • base is 0

Fully qualified path: alexandria_math::fast_power::fast_power

#![allow(unused)]
fn main() {
pub fn fast_power<
    T,
    +Div<T>,
    +DivAssign<T, T>,
    +Rem<T>,
    +Into<u8, T>,
    +Into<T, u256>,
    +TryInto<u256, T>,
    +PartialEq<T>,
    +Copy<T>,
    +Drop<T>,
>(
    base: T, mut power: T,
) -> T
}

fast_power_mod

Calculate the ( base ^ power ) mod modulus using the fast powering algorithm

Arguments

  • base - The base of the exponentiation
  • power - The power of the exponentiation
  • modulus - The modulus used in the calculation

Returns

  • T - The result of ( base ^ power ) mod modulus

Panics

  • base is 0

Fully qualified path: alexandria_math::fast_power::fast_power_mod

#![allow(unused)]
fn main() {
pub fn fast_power_mod<
    T,
    +Div<T>,
    +DivAssign<T, T>,
    +Rem<T>,
    +Into<u8, T>,
    +Into<T, u256>,
    +TryInto<u256, T>,
    +PartialEq<T>,
    +Copy<T>,
    +Drop<T>,
>(
    base: T, mut power: T, modulus: T,
) -> T
}

fast_nr_optimize

Newton-Raphson optimization to solve the equation a^r = x. The optimization has a quadratic convergence rate.

Arguments

  • x - The number to calculate the root of
  • r - The root to calculate
  • iter - The number of iterations to run the algorithm

Returns

  • u128 - The root of x with rounding. (e.g., sqrt(5) = 2.24 -> 2, sqrt(7) = 2.65 -> 3)

Fully qualified path: alexandria_math::fast_root::fast_nr_optimize

#![allow(unused)]
fn main() {
pub fn fast_nr_optimize(x: u128, r: u128, iter: usize) -> u128
}

fast_sqrt

Calculate the sqrt(x)

Arguments

  • x - The number to calculate the sqrt of
  • iter - The number of iterations to run the algorithm

Returns

  • u128 - The sqrt of x with rounding (e.g., sqrt(5) = 2.24 -> 2, sqrt(7) = 2.65 -> 3)

Fully qualified path: alexandria_math::fast_root::fast_sqrt

#![allow(unused)]
fn main() {
pub fn fast_sqrt(x: u128, iter: usize) -> u128
}

fast_cbrt

Calculate the cubic root of x

Arguments

  • x - The number to calculate the cubic root of
  • iter - The number of iterations to run the algorithm

Returns

  • u128 - The cubic root of x with rounding (e.g., cbrt(4) = 1.59 -> 2, cbrt(5) = 1.71 -> 2)

Fully qualified path: alexandria_math::fast_root::fast_cbrt

#![allow(unused)]
fn main() {
pub fn fast_cbrt(x: u128, iter: usize) -> u128
}

round_div

Calculate the division of a by b with rounding

Arguments

  • a - The dividend
  • b - The divisor

Returns

  • u128 - The result of the division with rounding (e.g., 5/3 = 2, 7/3 = 2, 8/3 = 3)

Fully qualified path: alexandria_math::fast_root::round_div

#![allow(unused)]
fn main() {
pub fn round_div(a: u128, b: u128) -> u128
}

fib

Fully qualified path: alexandria_math::fibonacci::fib

#![allow(unused)]
fn main() {
pub fn fib(a: felt252, b: felt252, n: felt252) -> felt252
}

gcd

Fully qualified path: alexandria_math::gcd_of_n_numbers::gcd

#![allow(unused)]
fn main() {
pub fn gcd(mut n: Span<u128>) -> u128
}

gcd_two_numbers

Fully qualified path: alexandria_math::gcd_of_n_numbers::gcd_two_numbers

#![allow(unused)]
fn main() {
pub fn gcd_two_numbers(mut a: u128, mut b: u128) -> u128
}

i257_div_rem

Fully qualified path: alexandria_math::i257::i257_div_rem

#![allow(unused)]
fn main() {
pub fn i257_div_rem(lhs: i257, rhs: i257) -> (i257, i257)
}

i257_assert_no_negative_zero

Fully qualified path: alexandria_math::i257::i257_assert_no_negative_zero

#![allow(unused)]
fn main() {
pub fn i257_assert_no_negative_zero(x: i257)
}

is_power_of_two

Check if the given number is power of 2.

Arguments

  • n - The given number

Returns

  • bool - if the given number is power of 2

Fully qualified path: alexandria_math::is_power_of_two::is_power_of_two

#![allow(unused)]
fn main() {
pub fn is_power_of_two(n: u128) -> bool
}

is_prime

Check if the given number is prime

Arguments

  • n - The given number
  • iter - The number of iterations to run when sqrting the number, the higher the more accurate (usually 10 is enough)

Returns

  • bool - if the given number is prime

Fully qualified path: alexandria_math::is_prime::is_prime

#![allow(unused)]
fn main() {
pub fn is_prime(n: u128, iter: usize) -> bool
}

multiply

Algorithm to multiply two numbers in O(n^1.6) running time

Arguments

  • x - First number to multiply.
  • y - Second number to multiply.

Returns

  • u128 - The product between x and y

Fully qualified path: alexandria_math::karatsuba::multiply

#![allow(unused)]
fn main() {
pub fn multiply(x: u128, y: u128) -> u128
}

keccak256

Computes the Solidity-compatible Keccak hash of an array of bytes.

Arguments

  • self - A Array<u8> of bytes.

Returns

A u256 value representing the Keccak hash of the input bytes array.

Fully qualified path: alexandria_math::keccak256::keccak256

#![allow(unused)]
fn main() {
pub fn keccak256(mut self: Span<u8>) -> u256
}

lcm

Calculate the lowest common multiple for n numbers

Arguments

  • n - The array of numbers to calculate the lcm for

Returns

  • Result<T, LCMError> - The lcm of input numbers

Fully qualified path: alexandria_math::lcm_of_n_numbers::lcm

#![allow(unused)]
fn main() {
pub fn lcm<T, +Into<T, u128>, +Into<u128, T>, +Mul<T>, +Div<T>, +Copy<T>, +Drop<T>>(
    mut n: Span<T>,
) -> Result<T, LCMError>
}

add_mod

Function that performs modular addition. Will panick if result is > u256 max

Arguments

  • a - Left hand side of addition.
  • b - Right hand side of addition.
  • modulo - modulo.

Returns

  • u256 - result of modular addition

Fully qualified path: alexandria_math::mod_arithmetics::add_mod

#![allow(unused)]
fn main() {
pub fn add_mod(a: u256, b: u256, modulo: u256) -> u256
}

mult_inverse

Function that return the modular multiplicative inverse. Disclaimer: this function should only be used with a prime modulo.

Arguments

  • b - Number of which to find the multiplicative inverse of.
  • modulo - modulo.

Returns

  • u256 - modular multiplicative inverse

Fully qualified path: alexandria_math::mod_arithmetics::mult_inverse

#![allow(unused)]
fn main() {
pub fn mult_inverse(b: u256, mod_non_zero: NonZero<u256>) -> u256
}

add_inverse_mod

Function that return the modular additive inverse.

Arguments

  • b - Number of which to find the additive inverse of.
  • modulo - modulo.

Returns

  • u256 - modular additive inverse

Fully qualified path: alexandria_math::mod_arithmetics::add_inverse_mod

#![allow(unused)]
fn main() {
pub fn add_inverse_mod(b: u256, modulo: u256) -> u256
}

sub_mod

Function that performs modular subtraction.

Arguments

  • a - Left hand side of subtraction.
  • b - Right hand side of subtraction.
  • modulo - modulo.

Returns

  • u256 - result of modular subtraction

Fully qualified path: alexandria_math::mod_arithmetics::sub_mod

#![allow(unused)]
fn main() {
pub fn sub_mod(mut a: u256, mut b: u256, modulo: u256) -> u256
}

mult_mod

Function that performs modular multiplication.

Arguments

  • a - Left hand side of multiplication.
  • b - Right hand side of multiplication.
  • modulo - modulo.

Returns

  • u256 - result of modular multiplication

Fully qualified path: alexandria_math::mod_arithmetics::mult_mod

#![allow(unused)]
fn main() {
pub fn mult_mod(a: u256, b: u256, mod_non_zero: NonZero<u256>) -> u256
}

u256_wide_sqr

Fully qualified path: alexandria_math::mod_arithmetics::u256_wide_sqr

#![allow(unused)]
fn main() {
pub fn u256_wide_sqr(a: u256) -> u512
}

sqr_mod

Function that performs modular multiplication.

Arguments

  • a - Left hand side of multiplication.
  • b - Right hand side of multiplication.
  • modulo - modulo.

Returns

  • u256 - result of modular multiplication

Fully qualified path: alexandria_math::mod_arithmetics::sqr_mod

#![allow(unused)]
fn main() {
pub fn sqr_mod(a: u256, mod_non_zero: NonZero<u256>) -> u256
}

div_mod

Function that performs modular division.

Arguments

  • a - Left hand side of division.
  • b - Right hand side of division.
  • modulo - modulo.

Returns

  • u256 - result of modular division

Fully qualified path: alexandria_math::mod_arithmetics::div_mod

#![allow(unused)]
fn main() {
pub fn div_mod(a: u256, b: u256, mod_non_zero: NonZero<u256>) -> u256
}

pow_mod

Function that performs modular exponentiation.

Arguments

  • base - Base of exponentiation.
  • pow - Power of exponentiation.
  • modulo - modulo.

Returns

  • u256 - result of modular exponentiation

Fully qualified path: alexandria_math::mod_arithmetics::pow_mod

#![allow(unused)]
fn main() {
pub fn pow_mod(mut base: u256, mut pow: u256, mod_non_zero: NonZero<u256>) -> u256
}

equality_mod

Fully qualified path: alexandria_math::mod_arithmetics::equality_mod

#![allow(unused)]
fn main() {
pub fn equality_mod(a: u256, b: u256, modulo: u256) -> bool
}

is_perfect_number

Algorithm to determine if a number is a perfect number

Arguments

  • num - The number to be checked.

Returns

  • bool - True if num is a perfect number, false otherwise.

Fully qualified path: alexandria_math::perfect_number::is_perfect_number

#![allow(unused)]
fn main() {
pub fn is_perfect_number(num: u128) -> bool
}

perfect_numbers

Algorithm to determine all the perfect numbers up to a maximum value

Arguments

  • max - The maximum value to check for perfect numbers.

Returns

  • Array - An array of perfect numbers up to the max value.

Fully qualified path: alexandria_math::perfect_number::perfect_numbers

#![allow(unused)]
fn main() {
pub fn perfect_numbers(max: u128) -> Array<u128>
}

sha256

Fully qualified path: alexandria_math::sha256::sha256

#![allow(unused)]
fn main() {
pub fn sha256(mut data: Array<u8>) -> Array<u8>
}

fpow

Calculates base ** power

Fully qualified path: alexandria_math::sha512::fpow

#![allow(unused)]
fn main() {
pub fn fpow(mut base: u128, mut power: u128) -> u128
}

two_pow

Fully qualified path: alexandria_math::sha512::two_pow

#![allow(unused)]
fn main() {
pub fn two_pow<T, +DivRem<T>, +Mul<T>, +Into<u64, T>, +Drop<T>>(mut power: u64) -> T
}

sha512

Fully qualified path: alexandria_math::sha512::sha512

#![allow(unused)]
fn main() {
pub fn sha512(mut data: Array<u8>) -> Array<u8>
}

fast_sin_inner

Fully qualified path: alexandria_math::trigonometry::fast_sin_inner

#![allow(unused)]
fn main() {
pub fn fast_sin_inner(x: u64) -> (bool, u64)
}

fast_sin

Fully qualified path: alexandria_math::trigonometry::fast_sin

#![allow(unused)]
fn main() {
pub fn fast_sin(x: i64) -> i64
}

fast_cos

Fully qualified path: alexandria_math::trigonometry::fast_cos

#![allow(unused)]
fn main() {
pub fn fast_cos(x: i64) -> i64
}

fast_tan

Fully qualified path: alexandria_math::trigonometry::fast_tan

#![allow(unused)]
fn main() {
pub fn fast_tan(x: i64) -> i64
}

u512_add

Adds two u512 values with overflow panic

Arguments

  • lhs - Left operand (u512)
  • rhs - Right operand (u512)

Returns

  • u512 - Sum of lhs and rhs

Panics

  • Panics if the addition would overflow u512 bounds

Fully qualified path: alexandria_math::u512_arithmetics::u512_add

#![allow(unused)]
fn main() {
pub fn u512_add(lhs: u512, rhs: u512) -> u512
}

u512_sub

Subtracts two u512 values with overflow panic

Arguments

  • lhs - Left operand (u512)
  • rhs - Right operand (u512)

Returns

  • u512 - Difference of lhs and rhs

Panics

  • Panics if the subtraction would underflow (result < 0)

Fully qualified path: alexandria_math::u512_arithmetics::u512_sub

#![allow(unused)]
fn main() {
pub fn u512_sub(lhs: u512, rhs: u512) -> u512
}

wad

Return the wad value

Returns

  • u256 - The value

Fully qualified path: alexandria_math::wad_ray_math::wad

#![allow(unused)]
fn main() {
pub fn wad() -> u256
}

ray

Return the ray value

Returns

  • u256 - The value

Fully qualified path: alexandria_math::wad_ray_math::ray

#![allow(unused)]
fn main() {
pub fn ray() -> u256
}

half_wad

Return the half wad value

Returns

  • u256 - The value

Fully qualified path: alexandria_math::wad_ray_math::half_wad

#![allow(unused)]
fn main() {
pub fn half_wad() -> u256
}

half_ray

Return the half ray value

Returns

  • u256 - The value

Fully qualified path: alexandria_math::wad_ray_math::half_ray

#![allow(unused)]
fn main() {
pub fn half_ray() -> u256
}

wad_mul

Multiplies two wad, rounding half up to the nearest wad

Arguments

  • a - Wad
  • b - Wad

Returns

  • a*b, in wad

Fully qualified path: alexandria_math::wad_ray_math::wad_mul

#![allow(unused)]
fn main() {
pub fn wad_mul(a: u256, b: u256) -> u256
}

wad_div

Divides two wad, rounding half up to the nearest wad

Arguments

  • a - Wad
  • b - Wad

Returns

  • a/b, in wad

Fully qualified path: alexandria_math::wad_ray_math::wad_div

#![allow(unused)]
fn main() {
pub fn wad_div(a: u256, b: u256) -> u256
}

ray_mul

Multiplies two ray, rounding half up to the nearest ray

Arguments

  • a - Ray
  • b - Ray

Returns

  • a raymul b

Fully qualified path: alexandria_math::wad_ray_math::ray_mul

#![allow(unused)]
fn main() {
pub fn ray_mul(a: u256, b: u256) -> u256
}

ray_div

Divides two ray, rounding half up to the nearest ray

Arguments

  • a - Ray
  • b - Ray

Returns

  • a - raydiv b

Fully qualified path: alexandria_math::wad_ray_math::ray_div

#![allow(unused)]
fn main() {
pub fn ray_div(a: u256, b: u256) -> u256
}

ray_to_wad

Casts ray down to wad

Arguments

  • a Ray

Returns

  • a converted to wad, rounded half up to the nearest wad

Fully qualified path: alexandria_math::wad_ray_math::ray_to_wad

#![allow(unused)]
fn main() {
pub fn ray_to_wad(a: u256) -> u256
}

wad_to_ray

Converts wad up to ray

Arguments

  • a Wad

Returns

  • a converted to ray

Fully qualified path: alexandria_math::wad_ray_math::wad_to_ray

#![allow(unused)]
fn main() {
pub fn wad_to_ray(a: u256) -> u256
}

day_of_week

Compute the day of the week for the given Gregorian date. The returned value is an integer in the range 0 to 6, where 0 is Saturday, 1 is Sunday, 2 is Monday, and so on.

Arguments

  • date - The date of the month
  • month - The month of the year
  • year - The year

Returns

  • Option::None - If the input parameters are invalid
  • Option::Some(day_of_week) - The day of the week

Examples

use alexandria::math::zellers_congruence::day_of_week;
let day_of_week = day_of_week(1, 1, 2020);

TODO - Change the return type to Result

Fully qualified path: alexandria_math::zellers_congruence::day_of_week

#![allow(unused)]
fn main() {
pub fn day_of_week(mut date: u128, mut month: u128, mut year: u128) -> Option<u128>
}

check_input_parameters

Check the input parameters for the day_of_week function.

Arguments

  • date - The date of the month
  • month - The month of the year
  • year - The year

Returns

  • true - If the input parameters are valid
  • false - If the input parameters are invalid

Fully qualified path: alexandria_math::zellers_congruence::check_input_parameters

#![allow(unused)]
fn main() {
pub fn check_input_parameters(date: u128, month: u128, year: u128) -> bool
}

Structs

Point

Fully qualified path: alexandria_math::ed25519::Point

#![allow(unused)]
fn main() {
#[derive(Drop, Copy)]
pub struct Point {
    pub x: u256,
    pub y: u256,
}
}

Members

x

Fully qualified path: alexandria_math::ed25519::Point::x

#![allow(unused)]
fn main() {
pub x: u256
}

y

Fully qualified path: alexandria_math::ed25519::Point::y

#![allow(unused)]
fn main() {
pub y: u256
}

i257

Fully qualified path: alexandria_math::i257::i257

#![allow(unused)]
fn main() {
#[derive(Serde, Copy, Drop, Hash)]
pub struct i257 {
    abs: u256,
    is_negative: bool,
}
}

Word64

Fully qualified path: alexandria_math::sha512::Word64

#![allow(unused)]
fn main() {
#[derive(Drop, Copy)]
pub struct Word64 {
    pub data: u64,
}
}

Members

data

Fully qualified path: alexandria_math::sha512::Word64::data

#![allow(unused)]
fn main() {
pub data: u64
}

u256X2

Fully qualified path: alexandria_math::u512_arithmetics::u256X2

#![allow(unused)]
fn main() {
#[derive(Copy, Drop, Hash, PartialEq, Serde)]
pub struct u256X2 {
    low: u256,
    high: u256,
}
}

Enums

LCMError

Fully qualified path: alexandria_math::lcm_of_n_numbers::LCMError

#![allow(unused)]
fn main() {
#[derive(Drop, Copy, PartialEq)]
pub enum LCMError {
    EmptyInput,
}
}

Variants

EmptyInput

Fully qualified path: alexandria_math::lcm_of_n_numbers::LCMError::EmptyInput

#![allow(unused)]
fn main() {
EmptyInput
}

Traits

BitShift

Fully qualified path: alexandria_math::BitShift

#![allow(unused)]
fn main() {
pub trait BitShift<
    T, +Sub<T>, +Mul<T>, +Div<T>, +Rem<T>, +PartialEq<T>, +Into<u8, T>, +Drop<T>, +Copy<T>,
>
}

Trait functions

shl

Fully qualified path: alexandria_math::BitShift::shl

#![allow(unused)]
fn main() {
fn shl(x: T, n: T) -> T
}

shr

Fully qualified path: alexandria_math::BitShift::shr

#![allow(unused)]
fn main() {
fn shr(x: T, n: T) -> T
}

BitmapTrait

Fully qualified path: alexandria_math::bitmap::BitmapTrait

#![allow(unused)]
fn main() {
pub trait BitmapTrait<
    T,
    +Add<T>,
    +Sub<T>,
    +Mul<T>,
    +Div<T>,
    +DivAssign<T, T>,
    +Rem<T>,
    +BitAnd<T>,
    +BitOr<T>,
    +BitNot<T>,
    +PartialEq<T>,
    +PartialOrd<T>,
    +Into<u8, T>,
    +Into<T, u256>,
    +TryInto<u256, T>,
    +Drop<T>,
    +Copy<T>,
>
}

Trait functions

get_bit_at

The bit value at the provided index of a number.

Arguments

  • x - The value for which to extract the bit value.
  • i - The index.

Returns

  • The value at index.

Fully qualified path: alexandria_math::bitmap::BitmapTrait::get_bit_at

#![allow(unused)]
fn main() {
fn get_bit_at(x: T, i: u8) -> bool
}

set_bit_at

Set the bit to value at the provided index of a number.

Arguments

  • x - The value for which to extract the bit value.
  • i - The index.
  • value - The value to set the bit to.

Returns

  • The value with the bit set to value.

Fully qualified path: alexandria_math::bitmap::BitmapTrait::set_bit_at

#![allow(unused)]
fn main() {
fn set_bit_at(x: T, i: u8, value: bool) -> T
}

most_significant_bit

The index of the most significant bit of the number, where the least significant bit is at index 0 and the most significant bit is at index 255

Arguments

  • x - The value for which to compute the most significant bit, must be greater than 0.

Returns

  • The index of the most significant bit

Fully qualified path: alexandria_math::bitmap::BitmapTrait::most_significant_bit

#![allow(unused)]
fn main() {
fn most_significant_bit(x: T) -> Option<u8>
}

least_significant_bit

The index of the least significant bit of the number, where the least significant bit is at index 0 and the most significant bit is at index 255

Arguments

  • x - The value for which to compute the least significant bit, must be greater than 0.

Returns

  • The index of the least significant bit

Fully qualified path: alexandria_math::bitmap::BitmapTrait::least_significant_bit

#![allow(unused)]
fn main() {
fn least_significant_bit(x: T) -> Option<u8>
}

nearest_left_significant_bit

The index of the nearest left significant bit to the index of a number.

Arguments

  • x - The value for which to compute the most significant bit.
  • i - The index for which to start the search.

Returns

  • The index of the nearest left significant bit, None is returned if no significant bit is found.

Fully qualified path: alexandria_math::bitmap::BitmapTrait::nearest_left_significant_bit

#![allow(unused)]
fn main() {
fn nearest_left_significant_bit(x: T, i: u8) -> Option<u8>
}

nearest_right_significant_bit

The index of the nearest right significant bit to the index of a number.

Arguments

  • x - The value for which to compute the most significant bit.
  • i - The index for which to start the search.

Returns

  • The index of the nearest right significant bit, None is returned if no significant bit is found.

Fully qualified path: alexandria_math::bitmap::BitmapTrait::nearest_right_significant_bit

#![allow(unused)]
fn main() {
fn nearest_right_significant_bit(x: T, i: u8) -> Option<u8>
}

nearest_significant_bit

The index of the nearest significant bit to the index of a number, where the least significant bit is at index 0 and the most significant bit is at index 255

Arguments

  • x - The value for which to compute the most significant bit, must be greater than 0.
  • i - The index for which to start the search.
  • priority - if priority is set to true then right is prioritized over left, left over right otherwise.

Returns

  • The index of the nearest significant bit, None is returned if no significant bit is found.

Fully qualified path: alexandria_math::bitmap::BitmapTrait::nearest_significant_bit

#![allow(unused)]
fn main() {
fn nearest_significant_bit(x: T, i: u8, priority: bool) -> Option<u8>
}

PointOperations

Fully qualified path: alexandria_math::ed25519::PointOperations

#![allow(unused)]
fn main() {
pub trait PointOperations<T>
}

Trait functions

double

Fully qualified path: alexandria_math::ed25519::PointOperations::double

#![allow(unused)]
fn main() {
fn double(self: T, prime_nz: NonZero<u256>) -> T
}

add

Fully qualified path: alexandria_math::ed25519::PointOperations::add

#![allow(unused)]
fn main() {
fn add(self: T, rhs: T, prime_nz: NonZero<u256>) -> T
}

I257Trait

Fully qualified path: alexandria_math::i257::I257Trait

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

Trait functions

new

Creates a new i257 from an absolute value and sign. Ensures zero is always represented as positive.

Arguments

  • abs - The absolute value as a u256
  • is_negative - Whether the number is negative

Returns

  • i257 - The constructed signed integer

Fully qualified path: alexandria_math::i257::I257Trait::new

#![allow(unused)]
fn main() {
fn new(abs: u256, is_negative: bool) -> i257
}

is_negative

Returns whether the i257 is negative.

Arguments

  • self - The i257 to check

Returns

  • bool - true if negative, false if positive or zero

Fully qualified path: alexandria_math::i257::I257Trait::is_negative

#![allow(unused)]
fn main() {
fn is_negative(self: i257) -> bool
}

abs

Returns the absolute value of the i257.

Arguments

  • self - The i257 to get absolute value from

Returns

  • u256 - The absolute value

Fully qualified path: alexandria_math::i257::I257Trait::abs

#![allow(unused)]
fn main() {
fn abs(self: i257) -> u256
}

WordOperations

Trait defining bitwise operations for word types used in cryptographic algorithms.

Fully qualified path: alexandria_math::sha512::WordOperations

#![allow(unused)]
fn main() {
pub trait WordOperations<T>
}

Trait functions

shr

Performs logical right shift operation.

Arguments

  • self - The value to shift
  • n - Number of positions to shift right

Returns

  • T - The shifted value

Fully qualified path: alexandria_math::sha512::WordOperations::shr

#![allow(unused)]
fn main() {
fn shr(self: T, n: u64) -> T
}

shl

Performs logical left shift operation.

Arguments

  • self - The value to shift
  • n - Number of positions to shift left

Returns

  • T - The shifted value

Fully qualified path: alexandria_math::sha512::WordOperations::shl

#![allow(unused)]
fn main() {
fn shl(self: T, n: u64) -> T
}

rotr

Performs rotate right operation.

Arguments

  • self - The value to rotate
  • n - Number of positions to rotate right

Returns

  • T - The rotated value

Fully qualified path: alexandria_math::sha512::WordOperations::rotr

#![allow(unused)]
fn main() {
fn rotr(self: T, n: u64) -> T
}

rotr_precomputed

Performs rotate right with precomputed power values for efficiency.

Arguments

  • self - The value to rotate
  • two_pow_n - Precomputed value of 2^n
  • two_pow_64_n - Precomputed value of 2^(64-n)

Returns

  • T - The rotated value

Fully qualified path: alexandria_math::sha512::WordOperations::rotr_precomputed

#![allow(unused)]
fn main() {
fn rotr_precomputed(self: T, two_pow_n: u64, two_pow_64_n: u64) -> T
}

rotl

Performs rotate left operation.

Arguments

  • self - The value to rotate
  • n - Number of positions to rotate left

Returns

  • T - The rotated value

Fully qualified path: alexandria_math::sha512::WordOperations::rotl

#![allow(unused)]
fn main() {
fn rotl(self: T, n: u64) -> T
}

Impls

U8BitShift

Fully qualified path: alexandria_math::U8BitShift

#![allow(unused)]
fn main() {
pub impl U8BitShift of BitShift<u8>
}

Impl functions

shl

Fully qualified path: alexandria_math::U8BitShift::shl

#![allow(unused)]
fn main() {
fn shl(x: u8, n: u8) -> u8
}

U16BitShift

Fully qualified path: alexandria_math::U16BitShift

#![allow(unused)]
fn main() {
pub impl U16BitShift of BitShift<u16>
}

Impl functions

shl

Fully qualified path: alexandria_math::U16BitShift::shl

#![allow(unused)]
fn main() {
fn shl(x: u16, n: u16) -> u16
}

U32BitShift

Fully qualified path: alexandria_math::U32BitShift

#![allow(unused)]
fn main() {
pub impl U32BitShift of BitShift<u32>
}

Impl functions

shl

Fully qualified path: alexandria_math::U32BitShift::shl

#![allow(unused)]
fn main() {
fn shl(x: u32, n: u32) -> u32
}

U64BitShift

Fully qualified path: alexandria_math::U64BitShift

#![allow(unused)]
fn main() {
pub impl U64BitShift of BitShift<u64>
}

Impl functions

shl

Fully qualified path: alexandria_math::U64BitShift::shl

#![allow(unused)]
fn main() {
fn shl(x: u64, n: u64) -> u64
}

U128BitShift

Fully qualified path: alexandria_math::U128BitShift

#![allow(unused)]
fn main() {
pub impl U128BitShift of BitShift<u128>
}

Impl functions

shl

Fully qualified path: alexandria_math::U128BitShift::shl

#![allow(unused)]
fn main() {
fn shl(x: u128, n: u128) -> u128
}

U256BitShift

Fully qualified path: alexandria_math::U256BitShift

#![allow(unused)]
fn main() {
pub impl U256BitShift of BitShift<u256>
}

Impl functions

shl

Fully qualified path: alexandria_math::U256BitShift::shl

#![allow(unused)]
fn main() {
fn shl(x: u256, n: u256) -> u256
}

U8BitRotate

Fully qualified path: alexandria_math::U8BitRotate

#![allow(unused)]
fn main() {
pub impl U8BitRotate of BitRotate<u8>
}

Impl functions

rotate_left

Fully qualified path: alexandria_math::U8BitRotate::rotate_left

#![allow(unused)]
fn main() {
fn rotate_left(x: u8, n: u8) -> u8
}

rotate_right

Fully qualified path: alexandria_math::U8BitRotate::rotate_right

#![allow(unused)]
fn main() {
fn rotate_right(x: u8, n: u8) -> u8
}

U16BitRotate

Fully qualified path: alexandria_math::U16BitRotate

#![allow(unused)]
fn main() {
pub impl U16BitRotate of BitRotate<u16>
}

Impl functions

rotate_left

Fully qualified path: alexandria_math::U16BitRotate::rotate_left

#![allow(unused)]
fn main() {
fn rotate_left(x: u16, n: u16) -> u16
}

rotate_right

Fully qualified path: alexandria_math::U16BitRotate::rotate_right

#![allow(unused)]
fn main() {
fn rotate_right(x: u16, n: u16) -> u16
}

U32BitRotate

Fully qualified path: alexandria_math::U32BitRotate

#![allow(unused)]
fn main() {
pub impl U32BitRotate of BitRotate<u32>
}

Impl functions

rotate_left

Fully qualified path: alexandria_math::U32BitRotate::rotate_left

#![allow(unused)]
fn main() {
fn rotate_left(x: u32, n: u32) -> u32
}

rotate_right

Fully qualified path: alexandria_math::U32BitRotate::rotate_right

#![allow(unused)]
fn main() {
fn rotate_right(x: u32, n: u32) -> u32
}

U64BitRotate

Fully qualified path: alexandria_math::U64BitRotate

#![allow(unused)]
fn main() {
pub impl U64BitRotate of BitRotate<u64>
}

Impl functions

rotate_left

Fully qualified path: alexandria_math::U64BitRotate::rotate_left

#![allow(unused)]
fn main() {
fn rotate_left(x: u64, n: u64) -> u64
}

rotate_right

Fully qualified path: alexandria_math::U64BitRotate::rotate_right

#![allow(unused)]
fn main() {
fn rotate_right(x: u64, n: u64) -> u64
}

U128BitRotate

Fully qualified path: alexandria_math::U128BitRotate

#![allow(unused)]
fn main() {
pub impl U128BitRotate of BitRotate<u128>
}

Impl functions

rotate_left

Fully qualified path: alexandria_math::U128BitRotate::rotate_left

#![allow(unused)]
fn main() {
fn rotate_left(x: u128, n: u128) -> u128
}

rotate_right

Fully qualified path: alexandria_math::U128BitRotate::rotate_right

#![allow(unused)]
fn main() {
fn rotate_right(x: u128, n: u128) -> u128
}

U256BitRotate

Fully qualified path: alexandria_math::U256BitRotate

#![allow(unused)]
fn main() {
pub impl U256BitRotate of BitRotate<u256>
}

Impl functions

rotate_left

Fully qualified path: alexandria_math::U256BitRotate::rotate_left

#![allow(unused)]
fn main() {
fn rotate_left(x: u256, n: u256) -> u256
}

rotate_right

Fully qualified path: alexandria_math::U256BitRotate::rotate_right

#![allow(unused)]
fn main() {
fn rotate_right(x: u256, n: u256) -> u256
}

I257Impl

Fully qualified path: alexandria_math::i257::I257Impl

#![allow(unused)]
fn main() {
pub impl I257Impl of I257Trait
}

Impl functions

new

Creates a new i257 from an absolute value and sign. Ensures zero is always represented as positive.

Arguments

  • abs - The absolute value as a u256
  • is_negative - Whether the number is negative

Returns

  • i257 - The constructed signed integer

Fully qualified path: alexandria_math::i257::I257Impl::new

#![allow(unused)]
fn main() {
fn new(abs: u256, is_negative: bool) -> i257
}

is_negative

Returns whether the i257 is negative.

Arguments

  • self - The i257 to check

Returns

  • bool - true if negative, false if positive or zero

Fully qualified path: alexandria_math::i257::I257Impl::is_negative

#![allow(unused)]
fn main() {
fn is_negative(self: i257) -> bool
}

abs

Returns the absolute value of the i257.

Arguments

  • self - The i257 to get absolute value from

Returns

  • u256 - The absolute value

Fully qualified path: alexandria_math::i257::I257Impl::abs

#![allow(unused)]
fn main() {
fn abs(self: i257) -> u256
}

i257Zeroable

Fully qualified path: alexandria_math::i257::i257Zeroable

#![allow(unused)]
fn main() {
pub impl i257Zeroable of Zero<i257>
}

Impl functions

zero

Fully qualified path: alexandria_math::i257::i257Zeroable::zero

#![allow(unused)]
fn main() {
fn zero() -> i257
}

is_zero

Fully qualified path: alexandria_math::i257::i257Zeroable::is_zero

#![allow(unused)]
fn main() {
fn is_zero(self: @i257) -> bool
}

is_non_zero

Fully qualified path: alexandria_math::i257::i257Zeroable::is_non_zero

#![allow(unused)]
fn main() {
fn is_non_zero(self: @i257) -> bool
}

DisplayI257Impl

Fully qualified path: alexandria_math::i257::DisplayI257Impl

#![allow(unused)]
fn main() {
pub impl DisplayI257Impl of Display<i257>
}

Impl functions

fmt

Fully qualified path: alexandria_math::i257::DisplayI257Impl::fmt

#![allow(unused)]
fn main() {
fn fmt(self: @i257, ref f: Formatter) -> Result<(), Error>
}

Word64WordOperations

Fully qualified path: alexandria_math::sha512::Word64WordOperations

#![allow(unused)]
fn main() {
pub impl Word64WordOperations of WordOperations<Word64>
}

Impl functions

shr

Fully qualified path: alexandria_math::sha512::Word64WordOperations::shr

#![allow(unused)]
fn main() {
fn shr(self: Word64, n: u64) -> Word64
}

shl

Fully qualified path: alexandria_math::sha512::Word64WordOperations::shl

#![allow(unused)]
fn main() {
fn shl(self: Word64, n: u64) -> Word64
}

rotr

Fully qualified path: alexandria_math::sha512::Word64WordOperations::rotr

#![allow(unused)]
fn main() {
fn rotr(self: Word64, n: u64) -> Word64
}

rotr_precomputed

Fully qualified path: alexandria_math::sha512::Word64WordOperations::rotr_precomputed

#![allow(unused)]
fn main() {
fn rotr_precomputed(self: Word64, two_pow_n: u64, two_pow_64_n: u64) -> Word64
}

rotl

Fully qualified path: alexandria_math::sha512::Word64WordOperations::rotl

#![allow(unused)]
fn main() {
fn rotl(self: Word64, n: u64) -> Word64
}

U512Intou256X2

Fully qualified path: alexandria_math::u512_arithmetics::U512Intou256X2

#![allow(unused)]
fn main() {
pub impl U512Intou256X2 of Into<u512, u256X2>
}

Impl functions

into

Fully qualified path: alexandria_math::u512_arithmetics::U512Intou256X2::into

#![allow(unused)]
fn main() {
fn into(self: u512) -> u256X2
}

Alexandria Merkle Tree

Fully qualified path: alexandria_merkle_tree

Modules

alexandria_merkle_tree

Fully qualified path: alexandria_merkle_tree

Modules

merkle_tree

MerkleTree implementation.

Examples

// This version uses the pedersen hash method because the PedersenHasherImpl is in the scope.
use alexandria_data_structures::merkle_tree::{Hasher, MerkleTree, pedersen::PedersenHasherImpl,
MerkleTreeTrait};

// Create a new merkle tree instance.
let mut merkle_tree: MerkleTree<Hasher> = MerkleTreeTrait::new();
let mut proof = array![element_1, element_2];
// Compute the merkle root.
let root = merkle_tree.compute_root(leaf, proof);
// This version uses the poseidon hash method because the PoseidonHasherImpl is in the scope.
use alexandria_data_structures::merkle_tree::{ Hasher, MerkleTree, poseidon::PoseidonHasherImpl,
MerkleTreeTrait };

// Create a new merkle tree instance.
let mut merkle_tree: MerkleTree<PoseidonHasher> = MerkleTreeTrait::new();
let mut proof = array![element_1, element_2];
// Compute the merkle root.
let root = merkle_tree.compute_root(leaf, proof);

Fully qualified path: alexandria_merkle_tree::merkle_tree

Modules

Structs

Traits

storage_proof

Fully qualified path: alexandria_merkle_tree::storage_proof

Free functions

Structs

Enums

Traits

Impls

pedersen

Hasher impls.

Fully qualified path: alexandria_merkle_tree::merkle_tree::pedersen

Impls

poseidon

Fully qualified path: alexandria_merkle_tree::merkle_tree::poseidon

Impls

Free functions

verify

Verify Starknet storage proof. For reference see: - (state) - (pathfinder_getproof API endpoint) - (pathfinder storage implementation)

Arguments

  • expected_state_commitment - state root proof is going to be verified against
  • contract_address - contract_address of the value to be verified
  • storage_address - storage_address of the value to be verified
  • proof - ContractStateProof representing storage proof

Returns

  • felt252 - value at storage_address if verified, panic otherwise.

Fully qualified path: alexandria_merkle_tree::storage_proof::verify

#![allow(unused)]
fn main() {
pub fn verify(
    expected_state_commitment: felt252,
    contract_address: felt252,
    storage_address: felt252,
    proof: ContractStateProof,
) -> felt252
}

Structs

Hasher

Fully qualified path: alexandria_merkle_tree::merkle_tree::Hasher

#![allow(unused)]
fn main() {
#[derive(Drop, Copy)]
pub struct Hasher {}
}

MerkleTree

MerkleTree representation.

Fully qualified path: alexandria_merkle_tree::merkle_tree::MerkleTree

#![allow(unused)]
fn main() {
#[derive(Drop)]
pub struct MerkleTree<T> {
    hasher: T,
}
}

StoredMerkleTree

Efficient MerkleTree with pre-built tree storage for O(log n) proof generation.

Fully qualified path: alexandria_merkle_tree::merkle_tree::StoredMerkleTree

#![allow(unused)]
fn main() {
#[derive(Drop)]
pub struct StoredMerkleTree<T> {
    hasher: T,
    levels: Array<Array<felt252>>,
    leaf_count: u32,
}
}

BinaryNode

Fully qualified path: alexandria_merkle_tree::storage_proof::BinaryNode

#![allow(unused)]
fn main() {
#[derive(Drop, Serde)]
pub struct BinaryNode {
    left: felt252,
    right: felt252,
}
}

EdgeNode

Fully qualified path: alexandria_merkle_tree::storage_proof::EdgeNode

#![allow(unused)]
fn main() {
#[derive(Drop, Copy, Serde)]
pub struct EdgeNode {
    path: felt252,
    child: felt252,
    length: u8,
}
}

ContractData

Fully qualified path: alexandria_merkle_tree::storage_proof::ContractData

#![allow(unused)]
fn main() {
#[derive(Destruct, Serde)]
pub struct ContractData {
    class_hash: felt252,
    nonce: felt252,
    contract_state_hash_version: felt252,
    storage_proof: Array<TrieNode>,
}
}

ContractStateProof

Fully qualified path: alexandria_merkle_tree::storage_proof::ContractStateProof

#![allow(unused)]
fn main() {
#[derive(Destruct, Serde)]
pub struct ContractStateProof {
    class_commitment: felt252,
    contract_proof: Array<TrieNode>,
    contract_data: ContractData,
}
}

Enums

TrieNode

Fully qualified path: alexandria_merkle_tree::storage_proof::TrieNode

#![allow(unused)]
fn main() {
#[derive(Drop, Serde)]
pub enum TrieNode {
    Binary: BinaryNode,
    Edge: EdgeNode,
}
}

Variants

Binary

Fully qualified path: alexandria_merkle_tree::storage_proof::TrieNode::Binary

#![allow(unused)]
fn main() {
Binary : BinaryNode
}

Edge

Fully qualified path: alexandria_merkle_tree::storage_proof::TrieNode::Edge

#![allow(unused)]
fn main() {
Edge : EdgeNode
}

Traits

HasherTrait

Hasher trait.

Fully qualified path: alexandria_merkle_tree::merkle_tree::HasherTrait

#![allow(unused)]
fn main() {
pub trait HasherTrait<T>
}

Trait functions

new

Fully qualified path: alexandria_merkle_tree::merkle_tree::HasherTrait::new

#![allow(unused)]
fn main() {
fn new() -> T
}

hash

Fully qualified path: alexandria_merkle_tree::merkle_tree::HasherTrait::hash

#![allow(unused)]
fn main() {
fn hash(ref self: T, data1: felt252, data2: felt252) -> felt252
}

MerkleTreeTrait

MerkleTree trait defining operations for Merkle tree construction and verification.

Fully qualified path: alexandria_merkle_tree::merkle_tree::MerkleTreeTrait

#![allow(unused)]
fn main() {
pub trait MerkleTreeTrait<T>
}

Trait functions

new

Create a new merkle tree instance.

Returns

  • MerkleTree<T> - A new merkle tree with the specified hasher type

Fully qualified path: alexandria_merkle_tree::merkle_tree::MerkleTreeTrait::new

#![allow(unused)]
fn main() {
fn new() -> MerkleTree<T>
}

compute_root

Compute the merkle root of a given proof by iteratively hashing with proof elements.

Arguments

  • self - The merkle tree instance
  • current_node - The starting leaf node (felt252 hash value)
  • proof - Array of sibling hashes needed to compute the root

Returns

  • felt252 - The computed merkle root hash

Fully qualified path: alexandria_merkle_tree::merkle_tree::MerkleTreeTrait::compute_root

#![allow(unused)]
fn main() {
fn compute_root(ref self: MerkleTree<T>, current_node: felt252, proof: Span<felt252>) -> felt252
}

verify

Verify that a leaf belongs to the merkle tree with the given root.

Arguments

  • self - The merkle tree instance
  • root - The expected merkle root hash
  • leaf - The leaf value to verify
  • proof - Array of sibling hashes for verification path

Returns

  • bool - True if the leaf is valid for the given root, false otherwise

Fully qualified path: alexandria_merkle_tree::merkle_tree::MerkleTreeTrait::verify

#![allow(unused)]
fn main() {
fn verify(ref self: MerkleTree<T>, root: felt252, leaf: felt252, proof: Span<felt252>) -> bool
}

compute_proof

Generate a merkle proof for a specific leaf at the given index. WARNING: This rebuilds the entire tree and is O(n) complexity. Use StoredMerkleTree for efficiency.

Arguments

  • self - The merkle tree instance
  • leaves - Array of all leaf values in the tree (will be sorted)
  • index - The index of the leaf to generate proof for

Returns

  • Span<felt252> - Array of sibling hashes forming the merkle proof

Fully qualified path: alexandria_merkle_tree::merkle_tree::MerkleTreeTrait::compute_proof

#![allow(unused)]
fn main() {
fn compute_proof(ref self: MerkleTree<T>, leaves: Array<felt252>, index: u32) -> Span<felt252>
}

BinaryNodeTrait

Fully qualified path: alexandria_merkle_tree::storage_proof::BinaryNodeTrait

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

Trait functions

new

Fully qualified path: alexandria_merkle_tree::storage_proof::BinaryNodeTrait::new

#![allow(unused)]
fn main() {
fn new(left: felt252, right: felt252) -> BinaryNode
}

EdgeNodeTrait

Fully qualified path: alexandria_merkle_tree::storage_proof::EdgeNodeTrait

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

Trait functions

new

Fully qualified path: alexandria_merkle_tree::storage_proof::EdgeNodeTrait::new

#![allow(unused)]
fn main() {
fn new(path: felt252, child: felt252, length: u8) -> EdgeNode
}

ContractDataTrait

Fully qualified path: alexandria_merkle_tree::storage_proof::ContractDataTrait

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

Trait functions

new

Fully qualified path: alexandria_merkle_tree::storage_proof::ContractDataTrait::new

#![allow(unused)]
fn main() {
fn new(
    class_hash: felt252,
    nonce: felt252,
    contract_state_hash_version: felt252,
    storage_proof: Array<TrieNode>,
) -> ContractData
}

ContractStateProofTrait

Fully qualified path: alexandria_merkle_tree::storage_proof::ContractStateProofTrait

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

Trait functions

new

Fully qualified path: alexandria_merkle_tree::storage_proof::ContractStateProofTrait::new

#![allow(unused)]
fn main() {
fn new(
    class_commitment: felt252, contract_proof: Array<TrieNode>, contract_data: ContractData,
) -> ContractStateProof
}

Impls

PedersenHasherImpl

Fully qualified path: alexandria_merkle_tree::merkle_tree::pedersen::PedersenHasherImpl

#![allow(unused)]
fn main() {
pub impl PedersenHasherImpl of HasherTrait<Hasher>
}

Impl functions

new

Fully qualified path: alexandria_merkle_tree::merkle_tree::pedersen::PedersenHasherImpl::new

#![allow(unused)]
fn main() {
fn new() -> Hasher
}

hash

Fully qualified path: alexandria_merkle_tree::merkle_tree::pedersen::PedersenHasherImpl::hash

#![allow(unused)]
fn main() {
fn hash(ref self: Hasher, data1: felt252, data2: felt252) -> felt252
}

PoseidonHasherImpl

Fully qualified path: alexandria_merkle_tree::merkle_tree::poseidon::PoseidonHasherImpl

#![allow(unused)]
fn main() {
pub impl PoseidonHasherImpl of HasherTrait<Hasher>
}

Impl functions

new

Fully qualified path: alexandria_merkle_tree::merkle_tree::poseidon::PoseidonHasherImpl::new

#![allow(unused)]
fn main() {
fn new() -> Hasher
}

hash

Fully qualified path: alexandria_merkle_tree::merkle_tree::poseidon::PoseidonHasherImpl::hash

#![allow(unused)]
fn main() {
fn hash(ref self: Hasher, data1: felt252, data2: felt252) -> felt252
}

BinaryNodeImpl

Fully qualified path: alexandria_merkle_tree::storage_proof::BinaryNodeImpl

#![allow(unused)]
fn main() {
pub impl BinaryNodeImpl of BinaryNodeTrait
}

Impl functions

new

Fully qualified path: alexandria_merkle_tree::storage_proof::BinaryNodeImpl::new

#![allow(unused)]
fn main() {
fn new(left: felt252, right: felt252) -> BinaryNode
}

EdgeNodeImpl

Fully qualified path: alexandria_merkle_tree::storage_proof::EdgeNodeImpl

#![allow(unused)]
fn main() {
pub impl EdgeNodeImpl of EdgeNodeTrait
}

Impl functions

new

Fully qualified path: alexandria_merkle_tree::storage_proof::EdgeNodeImpl::new

#![allow(unused)]
fn main() {
fn new(path: felt252, child: felt252, length: u8) -> EdgeNode
}

ContractDataImpl

Fully qualified path: alexandria_merkle_tree::storage_proof::ContractDataImpl

#![allow(unused)]
fn main() {
pub impl ContractDataImpl of ContractDataTrait
}

Impl functions

new

Fully qualified path: alexandria_merkle_tree::storage_proof::ContractDataImpl::new

#![allow(unused)]
fn main() {
fn new(
    class_hash: felt252,
    nonce: felt252,
    contract_state_hash_version: felt252,
    storage_proof: Array<TrieNode>,
) -> ContractData
}

ContractStateProofImpl

Fully qualified path: alexandria_merkle_tree::storage_proof::ContractStateProofImpl

#![allow(unused)]
fn main() {
pub impl ContractStateProofImpl of ContractStateProofTrait
}

Impl functions

new

Fully qualified path: alexandria_merkle_tree::storage_proof::ContractStateProofImpl::new

#![allow(unused)]
fn main() {
fn new(
    class_commitment: felt252, contract_proof: Array<TrieNode>, contract_data: ContractData,
) -> ContractStateProof
}

Alexandria Numeric

Fully qualified path: alexandria_numeric

Modules

alexandria_numeric

Fully qualified path: alexandria_numeric

Modules

cumprod

The cumulative product of the elements.

Fully qualified path: alexandria_numeric::cumprod

Free functions

cumsum

The cumulative sum of the elements.

Fully qualified path: alexandria_numeric::cumsum

Free functions

diff

Fully qualified path: alexandria_numeric::diff

Free functions

integers

Fully qualified path: alexandria_numeric::integers

Traits

interpolate

Fully qualified path: alexandria_numeric::interpolate

Free functions

Enums

trapezoidal_rule

Fully qualified path: alexandria_numeric::trapezoidal_rule

Free functions

Free functions

cumprod

Compute the cumulative product of a sequence.

Arguments

  • sequence - The sequence to operate.

Returns

  • Array<T> - The cumulative product of sequence.

Fully qualified path: alexandria_numeric::cumprod::cumprod

#![allow(unused)]
fn main() {
pub fn cumprod<T, +Mul<T>, +Copy<T>, +Drop<T>>(mut sequence: Span<T>) -> Array<T>
}

cumsum

Compute the cumulative sum of a sequence.

Arguments

  • sequence - The sequence to operate.

Returns

  • Array<T> - The cumulative sum of sequence.

Fully qualified path: alexandria_numeric::cumsum::cumsum

#![allow(unused)]
fn main() {
pub fn cumsum<T, +Add<T>, +Copy<T>, +Drop<T>>(mut sequence: Span<T>) -> Array<T>
}

diff

Compute the discrete difference of a sorted sequence.

Arguments

  • sequence - The sorted sequence to operate.

Returns

  • Array<T> - The discrete difference of sorted sequence.

Fully qualified path: alexandria_numeric::diff::diff

#![allow(unused)]
fn main() {
pub fn diff<T, +PartialOrd<T>, +Sub<T>, +Copy<T>, +Drop<T>, +Zero<T>>(
    mut sequence: Span<T>,
) -> Array<T>
}

interpolate

Interpolate y(x) at x.

Arguments

  • x - The position at which to interpolate.
  • xs - The sorted abscissa sequence of len L.
  • ys - The ordinate sequence of len L.
  • interpolation - The interpolation method to use.
  • extrapolation - The extrapolation method to use.

Returns

  • T - The interpolated y at x.

Fully qualified path: alexandria_numeric::interpolate::interpolate

#![allow(unused)]
fn main() {
pub fn interpolate<
    T, +PartialOrd<T>, +Add<T>, +Sub<T>, +Mul<T>, +Div<T>, +Zero<T>, +Copy<T>, +Drop<T>,
>(
    x: T, xs: Span<T>, ys: Span<T>, interpolation: Interpolation, extrapolation: Extrapolation,
) -> T
}

interpolate_fast

Fast interpolation function that uses binary search for efficient value lookup. Optimized version of interpolate() with O(log n) time complexity instead of O(n).

Time complexity: O(log n) due to binary search Space complexity: O(1)

Arguments

  • x - The position at which to interpolate
  • xs - The sorted abscissa sequence of length L (must be monotonically increasing)
  • ys - The ordinate sequence of length L corresponding to xs values
  • interpolation - The interpolation method to use (Linear, Nearest, ConstantLeft, ConstantRight)
  • extrapolation - The extrapolation method for values outside xs range (Null, Constant)

Returns

  • T - The interpolated/extrapolated value y at position x

Requirements

  • xs and ys must have the same length
  • xs must be sorted in ascending order
  • Both arrays must have at least 2 elements
  • Type T must implement required arithmetic and comparison traits

Panics

  • If xs and ys have different lengths
  • If arrays have fewer than 2 elements
  • If xs is not properly sorted
  • If binary search fails to find appropriate index

Fully qualified path: alexandria_numeric::interpolate::interpolate_fast

#![allow(unused)]
fn main() {
pub fn interpolate_fast<
    T, +PartialOrd<T>, +Add<T>, +Sub<T>, +Mul<T>, +Div<T>, +Zero<T>, +Copy<T>, +Drop<T>,
>(
    x: T, xs: Span<T>, ys: Span<T>, interpolation: Interpolation, extrapolation: Extrapolation,
) -> T
}

trapezoidal_rule

Integrate y(x).

Arguments

  • xs - The sorted abscissa sequence of len L.
  • ys - The ordinate sequence of len L.

Returns

  • T - The approximate integral.

Fully qualified path: alexandria_numeric::trapezoidal_rule::trapezoidal_rule

#![allow(unused)]
fn main() {
pub fn trapezoidal_rule<
    T,
    +PartialOrd<T>,
    +Add<T>,
    +AddAssign<T, T>,
    +Sub<T>,
    +Mul<T>,
    +Div<T>,
    +Copy<T>,
    +Drop<T>,
    +Zero<T>,
    +Into<u8, T>,
>(
    mut xs: Span<T>, mut ys: Span<T>,
) -> T
}

Enums

Interpolation

Fully qualified path: alexandria_numeric::interpolate::Interpolation

#![allow(unused)]
fn main() {
#[derive(Serde, Copy, Drop, PartialEq)]
pub enum Interpolation {
    Linear,
    Nearest,
    ConstantLeft,
    ConstantRight,
}
}

Variants

Linear

Fully qualified path: alexandria_numeric::interpolate::Interpolation::Linear

#![allow(unused)]
fn main() {
Linear
}

Nearest

Fully qualified path: alexandria_numeric::interpolate::Interpolation::Nearest

#![allow(unused)]
fn main() {
Nearest
}

ConstantLeft

Fully qualified path: alexandria_numeric::interpolate::Interpolation::ConstantLeft

#![allow(unused)]
fn main() {
ConstantLeft
}

ConstantRight

Fully qualified path: alexandria_numeric::interpolate::Interpolation::ConstantRight

#![allow(unused)]
fn main() {
ConstantRight
}

Extrapolation

Fully qualified path: alexandria_numeric::interpolate::Extrapolation

#![allow(unused)]
fn main() {
#[derive(Serde, Copy, Drop, PartialEq)]
pub enum Extrapolation {
    Null,
    Constant,
}
}

Variants

Null

Fully qualified path: alexandria_numeric::interpolate::Extrapolation::Null

#![allow(unused)]
fn main() {
Null
}

Constant

Fully qualified path: alexandria_numeric::interpolate::Extrapolation::Constant

#![allow(unused)]
fn main() {
Constant
}

Traits

UIntBytes

Fully qualified path: alexandria_numeric::integers::UIntBytes

#![allow(unused)]
fn main() {
pub trait UIntBytes<T>
}

Trait functions

from_bytes

Fully qualified path: alexandria_numeric::integers::UIntBytes::from_bytes

#![allow(unused)]
fn main() {
fn from_bytes(input: Span<u8>) -> Option<T>
}

to_bytes

Fully qualified path: alexandria_numeric::integers::UIntBytes::to_bytes

#![allow(unused)]
fn main() {
fn to_bytes(self: T) -> Span<u8>
}

Alexandria Searching

Fully qualified path: alexandria_searching

Modules

alexandria_searching

Fully qualified path: alexandria_searching

Modules

binary_search

Fully qualified path: alexandria_searching::binary_search

Free functions

bm_search

Fully qualified path: alexandria_searching::bm_search

Free functions

dijkstra

Fully qualified path: alexandria_searching::dijkstra

Free functions

Structs

Traits

Impls

levenshtein_distance

Fully qualified path: alexandria_searching::levenshtein_distance

Free functions

Free functions

binary_search

Performs binary search on a sorted span to find the exact position of a target value.

Time complexity: O(log n) Space complexity: O(log n) due to recursion

Arguments

  • span - A sorted span of elements to search in
  • val - The target value to search for

Returns

  • Option<u32> - Some(index) if value is found, None if not found

Requirements

  • The input span must be sorted in ascending order
  • Type T must implement Copy, Drop, PartialEq, and PartialOrd traits

Fully qualified path: alexandria_searching::binary_search::binary_search

#![allow(unused)]
fn main() {
pub fn binary_search<T, +Copy<T>, +Drop<T>, +PartialEq<T>, +PartialOrd<T>>(
    span: Span<T>, val: T,
) -> Option<u32>
}

binary_search_closest

Performs binary search to find the position where a value would be inserted to maintain sorted order, or the closest position to the target value.

Time complexity: O(log n) Space complexity: O(log n) due to recursion

Arguments

  • span - A sorted span of elements to search in
  • val - The target value to find the closest position for

Returns

  • Option<u32> - Some(index) of the closest position, None if span is empty or no valid position

Requirements

  • The input span must be sorted in ascending order
  • Type T must implement Copy, Drop, and PartialOrd traits

Behavior

  • Returns the index where val would fit in the sorted order
  • Useful for insertion points and range queries

Fully qualified path: alexandria_searching::binary_search::binary_search_closest

#![allow(unused)]
fn main() {
pub fn binary_search_closest<T, +Copy<T>, +Drop<T>, +PartialOrd<T>>(
    span: Span<T>, val: T,
) -> Option<u32>
}

bm_search

Find pattern in text and return the index of every match.

Arguments

  • text - The text to search in.
  • pattern - The pattern to search for.

Returns

  • Array<usize> - The index of every match.

Fully qualified path: alexandria_searching::bm_search::bm_search

#![allow(unused)]
fn main() {
pub fn bm_search(text: @ByteArray, pattern: @ByteArray) -> Array<usize>
}

dijkstra

Implements Dijkstra's shortest path algorithm to find shortest distances from a source node to all other nodes in a weighted graph with non-negative edge weights.

Time complexity: O((V + E) log V) where V is vertices and E is edges Space complexity: O(V) for distance tracking and priority queue

Arguments

  • self - The graph containing nodes and adjacency information
  • source - The starting node to calculate shortest paths from

Returns

  • Felt252Dict<u128> - Dictionary mapping node IDs to their shortest distances from source

Algorithm Overview

  1. Initialize all distances to infinity except source (distance 0)
  2. Use priority queue to always process the closest unvisited node
  3. For each node, update distances to its neighbors if a shorter path is found
  4. Mark nodes as visited to avoid reprocessing
  5. Continue until all reachable nodes are processed

Fully qualified path: alexandria_searching::dijkstra::dijkstra

#![allow(unused)]
fn main() {
pub fn dijkstra(ref self: Graph<Nullable<Span<Node>>>, source: u32) -> Felt252Dict<u128>
}

levenshtein_distance

Compute the edit distance between two byte arrays.

Arguments

  • arr1 - The first byte array.
  • arr2 - The second byte array.

Returns

  • usize - The edit distance between the two byte arrays.

Fully qualified path: alexandria_searching::levenshtein_distance::levenshtein_distance

#![allow(unused)]
fn main() {
pub fn levenshtein_distance(arr1: @ByteArray, arr2: @ByteArray) -> usize
}

Structs

Node

Fully qualified path: alexandria_searching::dijkstra::Node

#![allow(unused)]
fn main() {
#[derive(Copy, Drop)]
pub struct Node {
    source: u32,
    dest: u32,
    weight: u128,
}
}

Graph

Graph representation.

Fully qualified path: alexandria_searching::dijkstra::Graph

#![allow(unused)]
fn main() {
pub struct Graph<T> {
    pub(crate) nodes: Array<Node>,
    adj_nodes: Felt252Dict<T>,
}
}

Traits

GraphTrait

Graph trait defining operations for working with weighted directed graphs.

Fully qualified path: alexandria_searching::dijkstra::GraphTrait

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

Trait functions

new

Create a new empty graph instance.

Returns

  • Graph<Nullable<Span<Node>>> - A new empty graph

Fully qualified path: alexandria_searching::dijkstra::GraphTrait::new

#![allow(unused)]
fn main() {
fn new() -> Graph<Nullable<Span<Node>>>
}

add_edge

Add a weighted directed edge to the graph.

Arguments

  • self - The graph instance to modify
  • source - The source node ID
  • dest - The destination node ID
  • weight - The weight/cost of the edge

Fully qualified path: alexandria_searching::dijkstra::GraphTrait::add_edge

#![allow(unused)]
fn main() {
fn add_edge(ref self: Graph<Nullable<Span<Node>>>, source: u32, dest: u32, weight: u128)
}

shortest_path

Calculate shortest paths from a source node to all other nodes using Dijkstra's algorithm.

Arguments

  • self - The graph instance * source - The starting node ID to calculate paths from

Returns

  • Felt252Dict<u128> - Dictionary mapping node IDs to shortest distances

Fully qualified path: alexandria_searching::dijkstra::GraphTrait::shortest_path

#![allow(unused)]
fn main() {
fn shortest_path(ref self: Graph<Nullable<Span<Node>>>, source: u32) -> Felt252Dict<u128>
}

adj_nodes

Get adjacent nodes for a given source node.

Arguments

  • self - The graph instance
  • source - The node ID to get adjacencies for

Returns

  • Nullable<Span<Node>> - Span of adjacent nodes or null if none exist

Fully qualified path: alexandria_searching::dijkstra::GraphTrait::adj_nodes

#![allow(unused)]
fn main() {
fn adj_nodes(ref self: Graph<Nullable<Span<Node>>>, source: felt252) -> Nullable<Span<Node>>
}

NodeGettersTrait

Fully qualified path: alexandria_searching::dijkstra::NodeGettersTrait

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

Trait functions

weight

Fully qualified path: alexandria_searching::dijkstra::NodeGettersTrait::weight

#![allow(unused)]
fn main() {
fn weight(self: @Node) -> @u128
}

dest

Fully qualified path: alexandria_searching::dijkstra::NodeGettersTrait::dest

#![allow(unused)]
fn main() {
fn dest(self: @Node) -> @u32
}

source

Fully qualified path: alexandria_searching::dijkstra::NodeGettersTrait::source

#![allow(unused)]
fn main() {
fn source(self: @Node) -> @u32
}

Impls

NodeGetters

Fully qualified path: alexandria_searching::dijkstra::NodeGetters

#![allow(unused)]
fn main() {
pub impl NodeGetters of NodeGettersTrait
}

Impl functions

weight

Fully qualified path: alexandria_searching::dijkstra::NodeGetters::weight

#![allow(unused)]
fn main() {
fn weight(self: @Node) -> @u128
}

dest

Fully qualified path: alexandria_searching::dijkstra::NodeGetters::dest

#![allow(unused)]
fn main() {
fn dest(self: @Node) -> @u32
}

source

Fully qualified path: alexandria_searching::dijkstra::NodeGetters::source

#![allow(unused)]
fn main() {
fn source(self: @Node) -> @u32
}

Alexandria Sorting

Fully qualified path: alexandria_sorting

Modules

alexandria_sorting

Fully qualified path: alexandria_sorting

Modules

Traits

Impls

interface

Fully qualified path: alexandria_sorting::interface

Traits

merge_sort

Merge Sort

Fully qualified path: alexandria_sorting::merge_sort

Impls

quick_sort

Quick sort algorithm

Fully qualified path: alexandria_sorting::quick_sort

Impls

Traits

Sortable

Trait for sorting algorithms that work with Array spans

Fully qualified path: alexandria_sorting::interface::Sortable

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

Trait functions

sort

Sorts a span of elements and returns a new sorted array

Fully qualified path: alexandria_sorting::interface::Sortable::sort

#![allow(unused)]
fn main() {
fn sort<T, +Copy<T>, +Drop<T>, +PartialOrd<T>>(array: Span<T>) -> Array<T>
}

SortableVec

Trait for sorting algorithms that work with Felt252Vec

Fully qualified path: alexandria_sorting::interface::SortableVec

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

Trait functions

sort

Sorts a Felt252Vec and returns a new sorted Felt252Vec

Fully qualified path: alexandria_sorting::interface::SortableVec::sort

#![allow(unused)]
fn main() {
fn sort<T, +Copy<T>, +Drop<T>, +PartialOrd<T>, +Felt252DictValue<T>>(
    array: Felt252Vec<T>,
) -> Felt252Vec<T>
}

Impls

BubbleSort

Fully qualified path: alexandria_sorting::bubble_sort::BubbleSort

#![allow(unused)]
fn main() {
pub impl BubbleSort of Sortable
}

Impl functions

sort

Fully qualified path: alexandria_sorting::bubble_sort::BubbleSort::sort

#![allow(unused)]
fn main() {
fn sort<T, +Copy<T>, +Drop<T>, +PartialOrd<T>>(mut array: Span<T>) -> Array<T>
}

MergeSort

Fully qualified path: alexandria_sorting::merge_sort::MergeSort

#![allow(unused)]
fn main() {
pub impl MergeSort of Sortable
}

Impl functions

sort

Sorts an array using the merge sort algorithm.

Arguments

  • arr - Array to sort

Returns

  • Array<T> - Sorted array

Fully qualified path: alexandria_sorting::merge_sort::MergeSort::sort

#![allow(unused)]
fn main() {
fn sort<T, +Copy<T>, +Drop<T>, +PartialOrd<T>>(mut array: Span<T>) -> Array<T>
}

QuickSort

Implementation of QuickSort algorithm for Felt252Vec

Fully qualified path: alexandria_sorting::quick_sort::QuickSort

#![allow(unused)]
fn main() {
pub impl QuickSort of SortableVec
}

Impl functions

sort

Sorts a Felt252Vec using the QuickSort algorithm. Time complexity: O(n log n) average case, O(n²) worst case. Space complexity: O(log n) due to recursion.

Arguments

  • Felt252Vec<T> - Array to sort

Returns

  • Felt252Vec<T> - Sorted array

Fully qualified path: alexandria_sorting::quick_sort::QuickSort::sort

#![allow(unused)]
fn main() {
fn sort<T, +Copy<T>, +Drop<T>, +PartialOrd<T>, +Felt252DictValue<T>>(
    mut array: Felt252Vec<T>,
) -> Felt252Vec<T>
}

Alexandria Storage

Fully qualified path: alexandria_storage

Modules

alexandria_storage

Fully qualified path: alexandria_storage

Modules

Structs

Traits

list

Fully qualified path: alexandria_storage::list

Structs

Traits

Structs

List

Fully qualified path: alexandria_storage::list::List

#![allow(unused)]
fn main() {
#[derive(Drop)]
pub struct List<T> {
    pub(crate) address_domain: u32,
    pub(crate) base: StorageBaseAddress,
    len: u32,
}
}

Traits

ListTrait

Fully qualified path: alexandria_storage::list::ListTrait

#![allow(unused)]
fn main() {
pub trait ListTrait<T>
}

Trait functions

new

Instantiates a new List with the given base address.

Arguments

  • address_domain - The domain of the address. Only address_domain 0 is currently supported, in the future it will enable access to address spaces with different data availability
  • base - The base address of the List. This corresponds to the location in storage of the List's first element.

Returns

A new List.

Fully qualified path: alexandria_storage::list::ListTrait::new

#![allow(unused)]
fn main() {
fn new(address_domain: u32, base: StorageBaseAddress) -> List<T>
}

fetch

Fetches an existing List stored at the given base address. Returns an error if the storage read fails.

Arguments

  • address_domain - The domain of the address. Only address_domain 0 is currently supported, in the future it will enable access to address spaces with different data availability
  • base - The base address of the List. This corresponds to the location in storage of the List's first element.

Returns

An instance of the List fetched from storage, or an error in SyscallResult.

Fully qualified path: alexandria_storage::list::ListTrait::fetch

#![allow(unused)]
fn main() {
fn fetch(address_domain: u32, base: StorageBaseAddress) -> SyscallResult<List<T>>
}

append_span

Appends an existing Span to a List. Returns an error if the span cannot be appended to the a list due to storage errors.

Arguments

  • self - The List to add the span to.
  • span - A Span to append to the List.

Returns

A List constructed from the span or an error in SyscallResult.

Fully qualified path: alexandria_storage::list::ListTrait::append_span

#![allow(unused)]
fn main() {
fn append_span(ref self: List<T>, span: Span<T>) -> SyscallResult<()>
}

len

Gets the length of the List.

Returns

The number of elements in the List.

Fully qualified path: alexandria_storage::list::ListTrait::len

#![allow(unused)]
fn main() {
fn len(self: @List<T>) -> u32
}

is_empty

Checks if the List is empty.

Returns

true if the List is empty, false otherwise.

Fully qualified path: alexandria_storage::list::ListTrait::is_empty

#![allow(unused)]
fn main() {
fn is_empty(self: @List<T>) -> bool
}

append

Appends a value to the end of the List. Returns an error if the append operation fails due to reasons such as storage issues.

Arguments

  • value - The value to append.

Returns

The index at which the value was appended or an error in SyscallResult.

Fully qualified path: alexandria_storage::list::ListTrait::append

#![allow(unused)]
fn main() {
fn append(ref self: List<T>, value: T) -> SyscallResult<u32>
}

get

Retrieves an element by index from the List. Returns an error if there is a retrieval issue.

Arguments

  • index - The index of the element to retrieve.

Returns

An Option<T> which is None if the list is empty, or Some(value) if an element was found, encapsulated in SyscallResult.

Fully qualified path: alexandria_storage::list::ListTrait::get

#![allow(unused)]
fn main() {
fn get(self: @List<T>, index: u32) -> SyscallResult<Option<T>>
}

set

Sets the value of an element at a given index.

Arguments

  • index - The index of the element to modify.
  • value - The value to set at the given index.

Returns

A result indicating success or encapsulating the error in SyscallResult.

PanicsPanics if the index is out of bounds.

Fully qualified path: alexandria_storage::list::ListTrait::set

#![allow(unused)]
fn main() {
fn set(ref self: List<T>, index: u32, value: T) -> SyscallResult<()>
}

clean

Clears the List by setting its length to 0.The storage is not actually cleared, only the length is set to 0. The values can still be accessible using low-level syscalls, but cannot be accessed through the list interface.

Fully qualified path: alexandria_storage::list::ListTrait::clean

#![allow(unused)]
fn main() {
fn clean(ref self: List<T>)
}

pop_front

Removes and returns the first element of the List.The storage is not actually cleared, only the length is decreased by one. The value popped can still be accessible using low-level syscalls, but cannot be accessed through the list interface.

Returns

An Option<T> which is None if the index is out of bounds, or Some(value) if an element was found at the given index, encapsulated in SyscallResult.

Fully qualified path: alexandria_storage::list::ListTrait::pop_front

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

array

Converts the List into an Array. If the list cannot be converted to an array due storage errors, an error is returned.

Returns

An Array<T> containing all the elements of the List, encapsulated in SyscallResult.

Fully qualified path: alexandria_storage::list::ListTrait::array

#![allow(unused)]
fn main() {
fn array(self: @List<T>) -> SyscallResult<Array<T>>
}

storage_size

Fully qualified path: alexandria_storage::list::ListTrait::storage_size

#![allow(unused)]
fn main() {
fn storage_size(self: @List<T>) -> u8
}

Alexandria Utils

Fully qualified path: alexandria_utils

Modules

alexandria_utils

Fully qualified path: alexandria_utils

Modules

fmt

Fully qualified path: alexandria_utils::fmt

Impl aliases

Impls

Impl aliases

EthAddressDisplay

Fully qualified path: alexandria_utils::fmt::EthAddressDisplay

#![allow(unused)]
fn main() {
pub impl EthAddressDisplay = display_felt252_based::TDisplay<EthAddress>;
}

ContractAddressDisplay

Fully qualified path: alexandria_utils::fmt::ContractAddressDisplay

#![allow(unused)]
fn main() {
pub impl ContractAddressDisplay = display_felt252_based::TDisplay<ContractAddress>;
}

ClassHashDisplay

Fully qualified path: alexandria_utils::fmt::ClassHashDisplay

#![allow(unused)]
fn main() {
pub impl ClassHashDisplay = display_felt252_based::TDisplay<ClassHash>;
}

StorageAddressDisplay

Fully qualified path: alexandria_utils::fmt::StorageAddressDisplay

#![allow(unused)]
fn main() {
pub impl StorageAddressDisplay = display_felt252_based::TDisplay<StorageAddress>;
}

EthAddressDebug

Fully qualified path: alexandria_utils::fmt::EthAddressDebug

#![allow(unused)]
fn main() {
pub impl EthAddressDebug = debug_display_based::TDebug<EthAddress>;
}

ContractAddressDebug

Fully qualified path: alexandria_utils::fmt::ContractAddressDebug

#![allow(unused)]
fn main() {
pub impl ContractAddressDebug = debug_display_based::TDebug<ContractAddress>;
}

ClassHashDebug

Fully qualified path: alexandria_utils::fmt::ClassHashDebug

#![allow(unused)]
fn main() {
pub impl ClassHashDebug = debug_display_based::TDebug<ClassHash>;
}

StorageAddressDebug

Fully qualified path: alexandria_utils::fmt::StorageAddressDebug

#![allow(unused)]
fn main() {
pub impl StorageAddressDebug = debug_display_based::TDebug<StorageAddress>;
}

Impls

SpanTDebug

Fully qualified path: alexandria_utils::fmt::SpanTDebug

#![allow(unused)]
fn main() {
pub impl SpanTDebug<T, +Display<T>, +Copy<T>> of Debug<Span<T>>
}

Impl functions

fmt

Fully qualified path: alexandria_utils::fmt::SpanTDebug::fmt

#![allow(unused)]
fn main() {
fn fmt(self: @Span<T>, ref f: Formatter) -> Result<(), Error>
}