aleo-std
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() {
println!("{:?}", aleo_std::get_cpu());
}
Storage
use aleo_std::prelude::*;
fn foo() {
println!("{:?} exists: {:?}", aleo_dir(), aleo_dir().exists());
println!("{:?} exists: {:?}", aleo_ledger_dir(2, StorageMode::Production), aleo_ledger_dir(2, StorageMode::Production).exists());
}
Time
use aleo_std::prelude::*;
#[time]
fn foo() -> u32 {
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 {
let timer = timer!("Arithmetic");
let x = 1 + 1;
lap!(timer);
let y = 1 + 1;
finish!(timer);
x + y
}