#aleo #std

aleo-std

A standard library for Aleo repositories

16 releases

0.1.15 Oct 5, 2022
0.1.14 May 30, 2022
0.1.12 Feb 27, 2022
0.1.8 Jan 17, 2022
0.1.4 Nov 30, 2021

#261 in Development tools

Download history 10222/week @ 2022-08-10 7338/week @ 2022-08-17 10860/week @ 2022-08-24 16302/week @ 2022-08-31 2853/week @ 2022-09-07 2549/week @ 2022-09-14 9279/week @ 2022-09-21 9017/week @ 2022-09-28 13569/week @ 2022-10-05 6919/week @ 2022-10-12 12687/week @ 2022-10-19 9778/week @ 2022-10-26 11777/week @ 2022-11-02 13123/week @ 2022-11-09 9941/week @ 2022-11-16 7014/week @ 2022-11-23

43,001 downloads per month
Used in 59 crates (7 directly)

GPL-3.0 license

6KB

aleo-std

Crates.io Authors License

aleo-std is a standard library of tools for use in AleoHQ repositories.

Usage Guide

To use this crate to your repository, add the following to your Cargo.toml:

[dependencies.aleo-std]
version = "0.1"

CPU

fn foo() {
    // Prints the CPU name.
    println!("{:?}", aleo_std::get_cpu());
}

Storage

use aleo_std::prelude::*;

fn foo() {
    // Prints the Aleo directory.
    println!("{:?} exists: {:?}", aleo_dir(), aleo_dir().exists());
    // Prints the Aleo ledger directory in production mode.
    println!("{:?} exists: {:?}", aleo_ledger_dir(2, None), aleo_ledger_dir(2, None).exists());
    // Prints the Aleo operator directory in production mode.
    println!("{:?} exists: {:?}", aleo_operator_dir(2, None), aleo_operator_dir(2, None).exists());
    // Prints the Aleo prover directory in production mode.
    println!("{:?} exists: {:?}", aleo_prover_dir(2, None), aleo_prover_dir(2, None).exists());
}

Time

use aleo_std::prelude::*;

#[time]
fn foo() -> u32 {
    // Insert expensive operation
    1 + 1
}

Timed

use aleo_std::prelude::*;

#[timed]
fn foo(y: i32) -> i32 {
    let mut x = 1;
    let d = 1_000;
    x += d;
    x += y;
    x
}

#[timed]
fn main() {
    foo(23);
}

Timer

use aleo_std::prelude::*;

fn foo() -> u32 {
    // Start the timer.
    let timer = timer!("Arithmetic");

    // Insert expensive operation
    let x = 1 + 1;

    // Print the elapsed time up to this point.
    lap!(timer);

    // Insert expensive operation
    let y = 1 + 1;

    // Print the total time elapsed.
    finish!(timer);

    x + y
}

Dependencies

~2MB
~45K SLoC