Skip to content

Commit 1bc4b1e

Browse files
committed
add Rust docs
1 parent c6bcabd commit 1bc4b1e

File tree

2 files changed

+8
-0
lines changed
  • src
    • experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic
    • stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic

2 files changed

+8
-0
lines changed

src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/ic/uuid.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ use crate::INTERNAL_CSPRNG;
55

66
pub struct NativeFunction;
77
impl JsFn for NativeFunction {
8+
/// This function is intended to be used to generate unique identifiers that the end-user developer cannot influence through re-seeding.
9+
/// This function removes the risk of an end-user developer repeating a seed and thus potentially causing collisions in unique identifiers.
10+
/// Any functionality that relies on Azle's implementation of `crypto.getRandomValues` or `randBytes` is subject to the re-seeding risk.
11+
/// Thus by default any internal unique identifiers in the Azle JavaScript runtime should be generated using this function or another method not subject to re-seeding risk.
812
fn call(context: &mut Context, _this_val: JsValue, _argv: &[JsValue]) -> JsValue {
913
INTERNAL_CSPRNG.with(|csprng_refcell| {
1014
let mut rng = csprng_refcell.borrow_mut();

src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/ic/uuid.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ use rquickjs::{Ctx, Function, Result};
33

44
use crate::INTERNAL_CSPRNG;
55

6+
/// This function is intended to be used to generate unique identifiers that the end-user developer cannot influence through re-seeding.
7+
/// This function removes the risk of an end-user developer repeating a seed and thus potentially causing collisions in unique identifiers.
8+
/// Any functionality that relies on Azle's implementation of `crypto.getRandomValues` or `randBytes` is subject to the re-seeding risk.
9+
/// Thus by default any internal unique identifiers in the Azle JavaScript runtime should be generated using this function or another method not subject to re-seeding risk.
610
pub fn get_function(ctx: Ctx) -> Result<Function> {
711
Function::new(ctx.clone(), move || -> Result<String> {
812
INTERNAL_CSPRNG.with(|csprng_refcell| {

0 commit comments

Comments
 (0)